mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
IR: Add MDExpression::ExprOperand
Port `DIExpression::Operand` over to `MDExpression::ExprOperand`. The logic is needed directly in `MDExpression` to support printing in assembly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229002 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -350,6 +350,38 @@ MDExpression *MDExpression::getImpl(LLVMContext &Context,
|
||||
DEFINE_GETIMPL_STORE_NO_OPS(MDExpression, (Elements));
|
||||
}
|
||||
|
||||
unsigned MDExpression::ExprOperand::getSize() const {
|
||||
switch (getOp()) {
|
||||
case dwarf::DW_OP_bit_piece:
|
||||
return 3;
|
||||
case dwarf::DW_OP_plus:
|
||||
return 2;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool MDExpression::isValid() const {
|
||||
for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
|
||||
// Check that there's space for the operand.
|
||||
if (I->get() + I->getSize() > E->get())
|
||||
return false;
|
||||
|
||||
// Check that the operand is valid.
|
||||
switch (I->getOp()) {
|
||||
default:
|
||||
return false;
|
||||
case dwarf::DW_OP_bit_piece:
|
||||
// Piece expressions must be at the end.
|
||||
return I->get() + I->getSize() == E->get();
|
||||
case dwarf::DW_OP_plus:
|
||||
case dwarf::DW_OP_deref:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
MDObjCProperty *MDObjCProperty::getImpl(
|
||||
LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
|
||||
MDString *GetterName, MDString *SetterName, unsigned Attributes,
|
||||
|
Reference in New Issue
Block a user