[PATCH] D115128: [TableGen][CodeEmitter] Introducing the VarLenCodeEmitterGen infrastructure

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 11 19:49:10 PST 2021


jrtc27 added inline comments.


================
Comment at: llvm/utils/TableGen/VarLenCodeEmitterGen.cpp:266
+  if (HwMode == -1)
+    OS << "  static const APInt InstBits[] = {\n";
+  else
----------------
myhsu wrote:
> craig.topper wrote:
> > I think this violates the no static global constructor rule?
> no, `InstBits` (and `InstBits_<HW mode>`) is a local variable. Here is how it looks in the generated .inc file:
> ```
> void M68kMCCodeEmitter::getBinaryCodeForInstr(const MCInst &MI,
>     SmallVectorImpl<MCFixup> &Fixups,
>     APInt &Inst,
>     APInt &Scratch,
>     const MCSubtargetInfo &STI) const {
>   static const APInt InstBits[] = {
>     APInt::getZeroWidth(),
>     APInt::getZeroWidth(),
>     APInt::getZeroWidth(),
> ...
> ```
A local variable with static storage duration, i.e. a static global that's scoped to the function


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115128/new/

https://reviews.llvm.org/D115128



More information about the llvm-commits mailing list