[llvm] [SystemZ][z/OS] Implement executePostLayoutBinding for GOFFObjectWriter (PR #67868)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 11:14:47 PDT 2023


================
@@ -1296,6 +1298,41 @@ void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) {
                                       4);
 }
 
+void SystemZAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
+  if (TM.getTargetTriple().isOSzOS()) {
+    auto *Sym = cast<MCSymbolGOFF>(getSymbol(GV));
+    Sym->setExecutable(GOFF::ESD_EXE_DATA);
+  }
+
+  return AsmPrinter::emitGlobalVariable(GV);
+}
+
+const MCExpr *SystemZAsmPrinter::lowerConstant(const Constant *CV) {
+  const Triple &TargetTriple = TM.getTargetTriple();
+  if (TargetTriple.isOSzOS()) {
+    const GlobalAlias *GA = dyn_cast<GlobalAlias>(CV);
+    const GlobalVariable *GV = dyn_cast<GlobalVariable>(CV);
+    const Function *FV = dyn_cast<Function>(CV);
+    bool IsFunc = !GV && (FV || (GA && isa<Function>(GA->getAliaseeObject())));
+    MCSymbolGOFF *Sym = NULL;
+
+    if (GA)
+      Sym = cast<MCSymbolGOFF>(getSymbol(GA));
+    else if (IsFunc)
+      Sym = cast<MCSymbolGOFF>(getSymbol(FV));
+    else if (GV)
+      Sym = cast<MCSymbolGOFF>(getSymbol(GV));
----------------
diggerlin wrote:

`GlobalAlias ,  GlobalVariable ,Function` are derived from `GlobalValue`

```
if (GA)
      Sym = cast<MCSymbolGOFF>(getSymbol(GA));
    else if (IsFunc)
      Sym = cast<MCSymbolGOFF>(getSymbol(FV));
    else if (GV)
      Sym = cast<MCSymbolGOFF>(getSymbol(GV));
```

-->

```
if(auto GValue = dyn_cast<GlobalVValue>(CV)) 
   Sym = cast<MCSymbolGOFF>(getSymbol(GValue ));
```

https://github.com/llvm/llvm-project/pull/67868


More information about the llvm-commits mailing list