[Mlir-commits] [mlir] [mlir] Add support for DIGlobalVariable and DIGlobalVariableExpression (PR #73367)
Justin Wilson
llvmlistbot at llvm.org
Sat Nov 25 12:38:35 PST 2023
================
@@ -109,3 +119,251 @@ bool MemoryEffectsAttr::isReadWrite() {
return false;
return true;
}
+
+//===----------------------------------------------------------------------===//
+// DIExpression
+//===----------------------------------------------------------------------===//
+
+DIExpressionAttr DIExpressionAttr::get(MLIRContext *context) {
+ return get(context, ArrayRef<uint64_t>({}));
+}
+
+#define _FORMAT_DW_OP(x) #x
+#define FORMAT_DW_OP(NAME, VENDOR) _FORMAT_DW_OP(DW_OP_##VENDOR##_##NAME)
+
+size_t queryNumOpParams(llvm::dwarf::LocationAtom op) {
+ switch (op) {
+ case llvm::dwarf::DW_OP_addr:
+ case llvm::dwarf::DW_OP_const1u:
+ case llvm::dwarf::DW_OP_const1s:
+ case llvm::dwarf::DW_OP_const2u:
+ case llvm::dwarf::DW_OP_const2s:
+ case llvm::dwarf::DW_OP_const4u:
+ case llvm::dwarf::DW_OP_const4s:
+ case llvm::dwarf::DW_OP_const8u:
+ case llvm::dwarf::DW_OP_const8s:
+ case llvm::dwarf::DW_OP_constu:
+ case llvm::dwarf::DW_OP_consts:
+ case llvm::dwarf::DW_OP_pick:
+ case llvm::dwarf::DW_OP_plus_uconst:
+ case llvm::dwarf::DW_OP_bra:
+ case llvm::dwarf::DW_OP_skip:
+ case llvm::dwarf::DW_OP_breg0:
+ case llvm::dwarf::DW_OP_breg1:
+ case llvm::dwarf::DW_OP_breg2:
+ case llvm::dwarf::DW_OP_breg3:
+ case llvm::dwarf::DW_OP_breg4:
+ case llvm::dwarf::DW_OP_breg5:
+ case llvm::dwarf::DW_OP_breg6:
+ case llvm::dwarf::DW_OP_breg7:
+ case llvm::dwarf::DW_OP_breg8:
+ case llvm::dwarf::DW_OP_breg9:
+ case llvm::dwarf::DW_OP_breg10:
+ case llvm::dwarf::DW_OP_breg11:
+ case llvm::dwarf::DW_OP_breg12:
+ case llvm::dwarf::DW_OP_breg13:
+ case llvm::dwarf::DW_OP_breg14:
+ case llvm::dwarf::DW_OP_breg15:
+ case llvm::dwarf::DW_OP_breg16:
+ case llvm::dwarf::DW_OP_breg17:
+ case llvm::dwarf::DW_OP_breg18:
+ case llvm::dwarf::DW_OP_breg19:
+ case llvm::dwarf::DW_OP_breg20:
+ case llvm::dwarf::DW_OP_breg21:
+ case llvm::dwarf::DW_OP_breg22:
+ case llvm::dwarf::DW_OP_breg23:
+ case llvm::dwarf::DW_OP_breg24:
+ case llvm::dwarf::DW_OP_breg25:
+ case llvm::dwarf::DW_OP_breg26:
+ case llvm::dwarf::DW_OP_breg27:
+ case llvm::dwarf::DW_OP_breg28:
+ case llvm::dwarf::DW_OP_breg29:
+ case llvm::dwarf::DW_OP_breg30:
+ case llvm::dwarf::DW_OP_breg31:
+ case llvm::dwarf::DW_OP_regx:
+ case llvm::dwarf::DW_OP_fbreg:
+ case llvm::dwarf::DW_OP_piece:
+ case llvm::dwarf::DW_OP_deref_size:
+ case llvm::dwarf::DW_OP_xderef_size:
+ case llvm::dwarf::DW_OP_call2:
+ case llvm::dwarf::DW_OP_call4:
+ case llvm::dwarf::DW_OP_call_ref:
+ case llvm::dwarf::DW_OP_addrx:
+ case llvm::dwarf::DW_OP_constx:
+ case llvm::dwarf::DW_OP_convert:
+ case llvm::dwarf::DW_OP_reinterpret:
+ return 1;
+ case llvm::dwarf::DW_OP_bregx:
+ case llvm::dwarf::DW_OP_bit_piece:
+ case llvm::dwarf::DW_OP_implicit_value:
+ case llvm::dwarf::DW_OP_implicit_pointer:
+ case llvm::dwarf::DW_OP_entry_value:
+ case llvm::dwarf::DW_OP_regval_type:
+ case llvm::dwarf::DW_OP_deref_type:
+ case llvm::dwarf::DW_OP_xderef_type:
+ return 2;
+ case llvm::dwarf::DW_OP_const_type:
+ return 3;
+ default:
+ return 0;
+ }
+}
+
+::mlir::Attribute DIExpressionAttr::parse(AsmParser &parser, Type type) {
----------------
waj334 wrote:
This worked quite well, but there is a gap in functionality for expressions like this:
`DW_OP_LLVM_convert, 16, DW_ATE_signed`
I think I can change DIExpressionElemAttr to use an ArrayAttr so int operands can be mixed with encoding keywords.
https://github.com/llvm/llvm-project/pull/73367
More information about the Mlir-commits
mailing list