DwarfExpression.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. //===- llvm/CodeGen/DwarfExpression.cpp - Dwarf Debug Framework -----------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file contains support for writing dwarf debug info into asm files.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "DwarfExpression.h"
  13. #include "DwarfCompileUnit.h"
  14. #include "llvm/ADT/APInt.h"
  15. #include "llvm/ADT/SmallBitVector.h"
  16. #include "llvm/BinaryFormat/Dwarf.h"
  17. #include "llvm/CodeGen/TargetRegisterInfo.h"
  18. #include "llvm/IR/DebugInfoMetadata.h"
  19. #include "llvm/Support/ErrorHandling.h"
  20. #include <algorithm>
  21. #include <cassert>
  22. #include <cstdint>
  23. using namespace llvm;
  24. void DwarfExpression::emitConstu(uint64_t Value) {
  25. if (Value < 32)
  26. emitOp(dwarf::DW_OP_lit0 + Value);
  27. else if (Value == std::numeric_limits<uint64_t>::max()) {
  28. // Only do this for 64-bit values as the DWARF expression stack uses
  29. // target-address-size values.
  30. emitOp(dwarf::DW_OP_lit0);
  31. emitOp(dwarf::DW_OP_not);
  32. } else {
  33. emitOp(dwarf::DW_OP_constu);
  34. emitUnsigned(Value);
  35. }
  36. }
  37. void DwarfExpression::addReg(int DwarfReg, const char *Comment) {
  38. assert(DwarfReg >= 0 && "invalid negative dwarf register number");
  39. assert((isUnknownLocation() || isRegisterLocation()) &&
  40. "location description already locked down");
  41. LocationKind = Register;
  42. if (DwarfReg < 32) {
  43. emitOp(dwarf::DW_OP_reg0 + DwarfReg, Comment);
  44. } else {
  45. emitOp(dwarf::DW_OP_regx, Comment);
  46. emitUnsigned(DwarfReg);
  47. }
  48. }
  49. void DwarfExpression::addBReg(int DwarfReg, int Offset) {
  50. assert(DwarfReg >= 0 && "invalid negative dwarf register number");
  51. assert(!isRegisterLocation() && "location description already locked down");
  52. if (DwarfReg < 32) {
  53. emitOp(dwarf::DW_OP_breg0 + DwarfReg);
  54. } else {
  55. emitOp(dwarf::DW_OP_bregx);
  56. emitUnsigned(DwarfReg);
  57. }
  58. emitSigned(Offset);
  59. }
  60. void DwarfExpression::addFBReg(int Offset) {
  61. emitOp(dwarf::DW_OP_fbreg);
  62. emitSigned(Offset);
  63. }
  64. void DwarfExpression::addOpPiece(unsigned SizeInBits, unsigned OffsetInBits) {
  65. if (!SizeInBits)
  66. return;
  67. const unsigned SizeOfByte = 8;
  68. if (OffsetInBits > 0 || SizeInBits % SizeOfByte) {
  69. emitOp(dwarf::DW_OP_bit_piece);
  70. emitUnsigned(SizeInBits);
  71. emitUnsigned(OffsetInBits);
  72. } else {
  73. emitOp(dwarf::DW_OP_piece);
  74. unsigned ByteSize = SizeInBits / SizeOfByte;
  75. emitUnsigned(ByteSize);
  76. }
  77. this->OffsetInBits += SizeInBits;
  78. }
  79. void DwarfExpression::addShr(unsigned ShiftBy) {
  80. emitConstu(ShiftBy);
  81. emitOp(dwarf::DW_OP_shr);
  82. }
  83. void DwarfExpression::addAnd(unsigned Mask) {
  84. emitConstu(Mask);
  85. emitOp(dwarf::DW_OP_and);
  86. }
  87. bool DwarfExpression::addMachineReg(const TargetRegisterInfo &TRI,
  88. unsigned MachineReg, unsigned MaxSize) {
  89. if (!TRI.isPhysicalRegister(MachineReg)) {
  90. if (isFrameRegister(TRI, MachineReg)) {
  91. DwarfRegs.push_back({-1, 0, nullptr});
  92. return true;
  93. }
  94. return false;
  95. }
  96. int Reg = TRI.getDwarfRegNum(MachineReg, false);
  97. // If this is a valid register number, emit it.
  98. if (Reg >= 0) {
  99. DwarfRegs.push_back({Reg, 0, nullptr});
  100. return true;
  101. }
  102. // Walk up the super-register chain until we find a valid number.
  103. // For example, EAX on x86_64 is a 32-bit fragment of RAX with offset 0.
  104. for (MCSuperRegIterator SR(MachineReg, &TRI); SR.isValid(); ++SR) {
  105. Reg = TRI.getDwarfRegNum(*SR, false);
  106. if (Reg >= 0) {
  107. unsigned Idx = TRI.getSubRegIndex(*SR, MachineReg);
  108. unsigned Size = TRI.getSubRegIdxSize(Idx);
  109. unsigned RegOffset = TRI.getSubRegIdxOffset(Idx);
  110. DwarfRegs.push_back({Reg, 0, "super-register"});
  111. // Use a DW_OP_bit_piece to describe the sub-register.
  112. setSubRegisterPiece(Size, RegOffset);
  113. return true;
  114. }
  115. }
  116. // Otherwise, attempt to find a covering set of sub-register numbers.
  117. // For example, Q0 on ARM is a composition of D0+D1.
  118. unsigned CurPos = 0;
  119. // The size of the register in bits.
  120. const TargetRegisterClass *RC = TRI.getMinimalPhysRegClass(MachineReg);
  121. unsigned RegSize = TRI.getRegSizeInBits(*RC);
  122. // Keep track of the bits in the register we already emitted, so we
  123. // can avoid emitting redundant aliasing subregs. Because this is
  124. // just doing a greedy scan of all subregisters, it is possible that
  125. // this doesn't find a combination of subregisters that fully cover
  126. // the register (even though one may exist).
  127. SmallBitVector Coverage(RegSize, false);
  128. for (MCSubRegIterator SR(MachineReg, &TRI); SR.isValid(); ++SR) {
  129. unsigned Idx = TRI.getSubRegIndex(MachineReg, *SR);
  130. unsigned Size = TRI.getSubRegIdxSize(Idx);
  131. unsigned Offset = TRI.getSubRegIdxOffset(Idx);
  132. Reg = TRI.getDwarfRegNum(*SR, false);
  133. if (Reg < 0)
  134. continue;
  135. // Intersection between the bits we already emitted and the bits
  136. // covered by this subregister.
  137. SmallBitVector CurSubReg(RegSize, false);
  138. CurSubReg.set(Offset, Offset + Size);
  139. // If this sub-register has a DWARF number and we haven't covered
  140. // its range, emit a DWARF piece for it.
  141. if (CurSubReg.test(Coverage)) {
  142. // Emit a piece for any gap in the coverage.
  143. if (Offset > CurPos)
  144. DwarfRegs.push_back({-1, Offset - CurPos, "no DWARF register encoding"});
  145. DwarfRegs.push_back(
  146. {Reg, std::min<unsigned>(Size, MaxSize - Offset), "sub-register"});
  147. if (Offset >= MaxSize)
  148. break;
  149. // Mark it as emitted.
  150. Coverage.set(Offset, Offset + Size);
  151. CurPos = Offset + Size;
  152. }
  153. }
  154. // Failed to find any DWARF encoding.
  155. if (CurPos == 0)
  156. return false;
  157. // Found a partial or complete DWARF encoding.
  158. if (CurPos < RegSize)
  159. DwarfRegs.push_back({-1, RegSize - CurPos, "no DWARF register encoding"});
  160. return true;
  161. }
  162. void DwarfExpression::addStackValue() {
  163. if (DwarfVersion >= 4)
  164. emitOp(dwarf::DW_OP_stack_value);
  165. }
  166. void DwarfExpression::addSignedConstant(int64_t Value) {
  167. assert(isImplicitLocation() || isUnknownLocation());
  168. LocationKind = Implicit;
  169. emitOp(dwarf::DW_OP_consts);
  170. emitSigned(Value);
  171. }
  172. void DwarfExpression::addUnsignedConstant(uint64_t Value) {
  173. assert(isImplicitLocation() || isUnknownLocation());
  174. LocationKind = Implicit;
  175. emitConstu(Value);
  176. }
  177. void DwarfExpression::addUnsignedConstant(const APInt &Value) {
  178. assert(isImplicitLocation() || isUnknownLocation());
  179. LocationKind = Implicit;
  180. unsigned Size = Value.getBitWidth();
  181. const uint64_t *Data = Value.getRawData();
  182. // Chop it up into 64-bit pieces, because that's the maximum that
  183. // addUnsignedConstant takes.
  184. unsigned Offset = 0;
  185. while (Offset < Size) {
  186. addUnsignedConstant(*Data++);
  187. if (Offset == 0 && Size <= 64)
  188. break;
  189. addStackValue();
  190. addOpPiece(std::min(Size - Offset, 64u), Offset);
  191. Offset += 64;
  192. }
  193. }
  194. bool DwarfExpression::addMachineRegExpression(const TargetRegisterInfo &TRI,
  195. DIExpressionCursor &ExprCursor,
  196. unsigned MachineReg,
  197. unsigned FragmentOffsetInBits) {
  198. auto Fragment = ExprCursor.getFragmentInfo();
  199. if (!addMachineReg(TRI, MachineReg, Fragment ? Fragment->SizeInBits : ~1U)) {
  200. LocationKind = Unknown;
  201. return false;
  202. }
  203. bool HasComplexExpression = false;
  204. auto Op = ExprCursor.peek();
  205. if (Op && Op->getOp() != dwarf::DW_OP_LLVM_fragment)
  206. HasComplexExpression = true;
  207. // If the register can only be described by a complex expression (i.e.,
  208. // multiple subregisters) it doesn't safely compose with another complex
  209. // expression. For example, it is not possible to apply a DW_OP_deref
  210. // operation to multiple DW_OP_pieces.
  211. if (HasComplexExpression && DwarfRegs.size() > 1) {
  212. DwarfRegs.clear();
  213. LocationKind = Unknown;
  214. return false;
  215. }
  216. // Handle simple register locations. If we are supposed to emit
  217. // a call site parameter expression and if that expression is just a register
  218. // location, emit it with addBReg and offset 0, because we should emit a DWARF
  219. // expression representing a value, rather than a location.
  220. if (!isMemoryLocation() && !HasComplexExpression && (!isParameterValue() ||
  221. isEntryValue())) {
  222. for (auto &Reg : DwarfRegs) {
  223. if (Reg.DwarfRegNo >= 0)
  224. addReg(Reg.DwarfRegNo, Reg.Comment);
  225. addOpPiece(Reg.Size);
  226. }
  227. if (isEntryValue() && !isParameterValue() && DwarfVersion >= 4)
  228. emitOp(dwarf::DW_OP_stack_value);
  229. DwarfRegs.clear();
  230. return true;
  231. }
  232. // Don't emit locations that cannot be expressed without DW_OP_stack_value.
  233. if (DwarfVersion < 4)
  234. if (any_of(ExprCursor, [](DIExpression::ExprOperand Op) -> bool {
  235. return Op.getOp() == dwarf::DW_OP_stack_value;
  236. })) {
  237. DwarfRegs.clear();
  238. LocationKind = Unknown;
  239. return false;
  240. }
  241. assert(DwarfRegs.size() == 1);
  242. auto Reg = DwarfRegs[0];
  243. bool FBReg = isFrameRegister(TRI, MachineReg);
  244. int SignedOffset = 0;
  245. assert(Reg.Size == 0 && "subregister has same size as superregister");
  246. // Pattern-match combinations for which more efficient representations exist.
  247. // [Reg, DW_OP_plus_uconst, Offset] --> [DW_OP_breg, Offset].
  248. if (Op && (Op->getOp() == dwarf::DW_OP_plus_uconst)) {
  249. SignedOffset = Op->getArg(0);
  250. ExprCursor.take();
  251. }
  252. // [Reg, DW_OP_constu, Offset, DW_OP_plus] --> [DW_OP_breg, Offset]
  253. // [Reg, DW_OP_constu, Offset, DW_OP_minus] --> [DW_OP_breg,-Offset]
  254. // If Reg is a subregister we need to mask it out before subtracting.
  255. if (Op && Op->getOp() == dwarf::DW_OP_constu) {
  256. auto N = ExprCursor.peekNext();
  257. if (N && (N->getOp() == dwarf::DW_OP_plus ||
  258. (N->getOp() == dwarf::DW_OP_minus && !SubRegisterSizeInBits))) {
  259. int Offset = Op->getArg(0);
  260. SignedOffset = (N->getOp() == dwarf::DW_OP_minus) ? -Offset : Offset;
  261. ExprCursor.consume(2);
  262. }
  263. }
  264. if (FBReg)
  265. addFBReg(SignedOffset);
  266. else
  267. addBReg(Reg.DwarfRegNo, SignedOffset);
  268. DwarfRegs.clear();
  269. return true;
  270. }
  271. void DwarfExpression::addEntryValueExpression(DIExpressionCursor &ExprCursor) {
  272. auto Op = ExprCursor.take();
  273. assert(Op && Op->getOp() == dwarf::DW_OP_entry_value);
  274. assert(!isMemoryLocation() &&
  275. "We don't support entry values of memory locations yet");
  276. if (DwarfVersion >= 5)
  277. emitOp(dwarf::DW_OP_entry_value);
  278. else
  279. emitOp(dwarf::DW_OP_GNU_entry_value);
  280. emitUnsigned(Op->getArg(0));
  281. }
  282. /// Assuming a well-formed expression, match "DW_OP_deref* DW_OP_LLVM_fragment?".
  283. static bool isMemoryLocation(DIExpressionCursor ExprCursor) {
  284. while (ExprCursor) {
  285. auto Op = ExprCursor.take();
  286. switch (Op->getOp()) {
  287. case dwarf::DW_OP_deref:
  288. case dwarf::DW_OP_LLVM_fragment:
  289. break;
  290. default:
  291. return false;
  292. }
  293. }
  294. return true;
  295. }
  296. void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor,
  297. unsigned FragmentOffsetInBits) {
  298. // If we need to mask out a subregister, do it now, unless the next
  299. // operation would emit an OpPiece anyway.
  300. auto N = ExprCursor.peek();
  301. if (SubRegisterSizeInBits && N && (N->getOp() != dwarf::DW_OP_LLVM_fragment))
  302. maskSubRegister();
  303. Optional<DIExpression::ExprOperand> PrevConvertOp = None;
  304. while (ExprCursor) {
  305. auto Op = ExprCursor.take();
  306. uint64_t OpNum = Op->getOp();
  307. if (OpNum >= dwarf::DW_OP_reg0 && OpNum <= dwarf::DW_OP_reg31) {
  308. emitOp(OpNum);
  309. continue;
  310. } else if (OpNum >= dwarf::DW_OP_breg0 && OpNum <= dwarf::DW_OP_breg31) {
  311. addBReg(OpNum - dwarf::DW_OP_breg0, Op->getArg(0));
  312. continue;
  313. }
  314. switch (OpNum) {
  315. case dwarf::DW_OP_LLVM_fragment: {
  316. unsigned SizeInBits = Op->getArg(1);
  317. unsigned FragmentOffset = Op->getArg(0);
  318. // The fragment offset must have already been adjusted by emitting an
  319. // empty DW_OP_piece / DW_OP_bit_piece before we emitted the base
  320. // location.
  321. assert(OffsetInBits >= FragmentOffset && "fragment offset not added?");
  322. // If addMachineReg already emitted DW_OP_piece operations to represent
  323. // a super-register by splicing together sub-registers, subtract the size
  324. // of the pieces that was already emitted.
  325. SizeInBits -= OffsetInBits - FragmentOffset;
  326. // If addMachineReg requested a DW_OP_bit_piece to stencil out a
  327. // sub-register that is smaller than the current fragment's size, use it.
  328. if (SubRegisterSizeInBits)
  329. SizeInBits = std::min<unsigned>(SizeInBits, SubRegisterSizeInBits);
  330. // Emit a DW_OP_stack_value for implicit location descriptions.
  331. if (isImplicitLocation())
  332. addStackValue();
  333. // Emit the DW_OP_piece.
  334. addOpPiece(SizeInBits, SubRegisterOffsetInBits);
  335. setSubRegisterPiece(0, 0);
  336. // Reset the location description kind.
  337. LocationKind = Unknown;
  338. return;
  339. }
  340. case dwarf::DW_OP_plus_uconst:
  341. assert(!isRegisterLocation());
  342. emitOp(dwarf::DW_OP_plus_uconst);
  343. emitUnsigned(Op->getArg(0));
  344. break;
  345. case dwarf::DW_OP_plus:
  346. case dwarf::DW_OP_minus:
  347. case dwarf::DW_OP_mul:
  348. case dwarf::DW_OP_div:
  349. case dwarf::DW_OP_mod:
  350. case dwarf::DW_OP_or:
  351. case dwarf::DW_OP_and:
  352. case dwarf::DW_OP_xor:
  353. case dwarf::DW_OP_shl:
  354. case dwarf::DW_OP_shr:
  355. case dwarf::DW_OP_shra:
  356. case dwarf::DW_OP_lit0:
  357. case dwarf::DW_OP_not:
  358. case dwarf::DW_OP_dup:
  359. emitOp(OpNum);
  360. break;
  361. case dwarf::DW_OP_deref:
  362. assert(!isRegisterLocation());
  363. if (!isMemoryLocation() && ::isMemoryLocation(ExprCursor))
  364. // Turning this into a memory location description makes the deref
  365. // implicit.
  366. LocationKind = Memory;
  367. else
  368. emitOp(dwarf::DW_OP_deref);
  369. break;
  370. case dwarf::DW_OP_constu:
  371. assert(!isRegisterLocation());
  372. emitConstu(Op->getArg(0));
  373. break;
  374. case dwarf::DW_OP_LLVM_convert: {
  375. unsigned BitSize = Op->getArg(0);
  376. dwarf::TypeKind Encoding = static_cast<dwarf::TypeKind>(Op->getArg(1));
  377. if (DwarfVersion >= 5) {
  378. emitOp(dwarf::DW_OP_convert);
  379. // Reuse the base_type if we already have one in this CU otherwise we
  380. // create a new one.
  381. unsigned I = 0, E = CU.ExprRefedBaseTypes.size();
  382. for (; I != E; ++I)
  383. if (CU.ExprRefedBaseTypes[I].BitSize == BitSize &&
  384. CU.ExprRefedBaseTypes[I].Encoding == Encoding)
  385. break;
  386. if (I == E)
  387. CU.ExprRefedBaseTypes.emplace_back(BitSize, Encoding);
  388. // If targeting a location-list; simply emit the index into the raw
  389. // byte stream as ULEB128, DwarfDebug::emitDebugLocEntry has been
  390. // fitted with means to extract it later.
  391. // If targeting a inlined DW_AT_location; insert a DIEBaseTypeRef
  392. // (containing the index and a resolve mechanism during emit) into the
  393. // DIE value list.
  394. emitBaseTypeRef(I);
  395. } else {
  396. if (PrevConvertOp && PrevConvertOp->getArg(0) < BitSize) {
  397. if (Encoding == dwarf::DW_ATE_signed)
  398. emitLegacySExt(PrevConvertOp->getArg(0));
  399. else if (Encoding == dwarf::DW_ATE_unsigned)
  400. emitLegacyZExt(PrevConvertOp->getArg(0));
  401. PrevConvertOp = None;
  402. } else {
  403. PrevConvertOp = Op;
  404. }
  405. }
  406. break;
  407. }
  408. case dwarf::DW_OP_stack_value:
  409. LocationKind = Implicit;
  410. break;
  411. case dwarf::DW_OP_swap:
  412. assert(!isRegisterLocation());
  413. emitOp(dwarf::DW_OP_swap);
  414. break;
  415. case dwarf::DW_OP_xderef:
  416. assert(!isRegisterLocation());
  417. emitOp(dwarf::DW_OP_xderef);
  418. break;
  419. case dwarf::DW_OP_deref_size:
  420. emitOp(dwarf::DW_OP_deref_size);
  421. emitData1(Op->getArg(0));
  422. break;
  423. case dwarf::DW_OP_LLVM_tag_offset:
  424. TagOffset = Op->getArg(0);
  425. break;
  426. case dwarf::DW_OP_regx:
  427. emitOp(dwarf::DW_OP_regx);
  428. emitUnsigned(Op->getArg(0));
  429. break;
  430. case dwarf::DW_OP_bregx:
  431. emitOp(dwarf::DW_OP_bregx);
  432. emitUnsigned(Op->getArg(0));
  433. emitSigned(Op->getArg(1));
  434. break;
  435. default:
  436. llvm_unreachable("unhandled opcode found in expression");
  437. }
  438. }
  439. if (isImplicitLocation() && !isParameterValue())
  440. // Turn this into an implicit location description.
  441. addStackValue();
  442. }
  443. /// add masking operations to stencil out a subregister.
  444. void DwarfExpression::maskSubRegister() {
  445. assert(SubRegisterSizeInBits && "no subregister was registered");
  446. if (SubRegisterOffsetInBits > 0)
  447. addShr(SubRegisterOffsetInBits);
  448. uint64_t Mask = (1ULL << (uint64_t)SubRegisterSizeInBits) - 1ULL;
  449. addAnd(Mask);
  450. }
  451. void DwarfExpression::finalize() {
  452. assert(DwarfRegs.size() == 0 && "dwarf registers not emitted");
  453. // Emit any outstanding DW_OP_piece operations to mask out subregisters.
  454. if (SubRegisterSizeInBits == 0)
  455. return;
  456. // Don't emit a DW_OP_piece for a subregister at offset 0.
  457. if (SubRegisterOffsetInBits == 0)
  458. return;
  459. addOpPiece(SubRegisterSizeInBits, SubRegisterOffsetInBits);
  460. }
  461. void DwarfExpression::addFragmentOffset(const DIExpression *Expr) {
  462. if (!Expr || !Expr->isFragment())
  463. return;
  464. uint64_t FragmentOffset = Expr->getFragmentInfo()->OffsetInBits;
  465. assert(FragmentOffset >= OffsetInBits &&
  466. "overlapping or duplicate fragments");
  467. if (FragmentOffset > OffsetInBits)
  468. addOpPiece(FragmentOffset - OffsetInBits);
  469. OffsetInBits = FragmentOffset;
  470. }
  471. void DwarfExpression::emitLegacySExt(unsigned FromBits) {
  472. // (((X >> (FromBits - 1)) * (~0)) << FromBits) | X
  473. emitOp(dwarf::DW_OP_dup);
  474. emitOp(dwarf::DW_OP_constu);
  475. emitUnsigned(FromBits - 1);
  476. emitOp(dwarf::DW_OP_shr);
  477. emitOp(dwarf::DW_OP_lit0);
  478. emitOp(dwarf::DW_OP_not);
  479. emitOp(dwarf::DW_OP_mul);
  480. emitOp(dwarf::DW_OP_constu);
  481. emitUnsigned(FromBits);
  482. emitOp(dwarf::DW_OP_shl);
  483. emitOp(dwarf::DW_OP_or);
  484. }
  485. void DwarfExpression::emitLegacyZExt(unsigned FromBits) {
  486. // (X & (1 << FromBits - 1))
  487. emitOp(dwarf::DW_OP_constu);
  488. emitUnsigned((1ULL << FromBits) - 1);
  489. emitOp(dwarf::DW_OP_and);
  490. }