llvm-project/llvm/test/CodeGen/SystemZ/zos-ada-relocations.ll
Kai Nacke 33872f1218
[GOFF] Add writing of section symbols (#133799)
Unlike other formats, the GOFF object file format uses a 2 dimensional structure
to define the location of data. For example, the equivalent of the ELF .text
section is made up of a Section Definition (SD) and a class (Element Definition;
ED). The name of the SD symbol depends on the application, while the class has
the predefined name C_CODE/C_CODE64 in AMODE31 and AMODE64 respectively.

Data can be placed into this structure in 2 ways. First, the data (in a text
record) can be associated with an ED symbol. To refer to data, a Label
Definition (LD) is used to give an offset into the data a name. When binding,
the whole data is pulled into the resulting executable, and the addresses
given by the LD symbols are resolved.

The alternative is to use a Part Definition (PR). In this case, the data (in
a text record) is associated with the part. When binding, only the data of
referenced PRs is pulled into the resulting binary.

Both approaches are used. SD, ED, and PR elements are modeled by nested
MCSectionGOFF instances, while LD elements are associated with MCSymbolGOFF
instances.

At the binary level, a record called "External Symbol Definition" (ESD) is used. The
ESD has a type (SD, ED, PR, LD), and depending on the type a different subset of
the fields is used.
2025-06-26 11:52:14 -04:00

70 lines
2.1 KiB
LLVM

; Test the ADA section in the assembly output for all cases.
;
; RUN: llc < %s -mtriple=s390x-ibm-zos | FileCheck %s
; CHECK-LABEL: DoIt:
; CHECK: stmg 6,7,1840(4)
; CHECK: aghi 4,-224
; CHECK: lg 1,0(5)
; CHECK: lg 6,16(5)
; CHECK: lg 5,8(5)
; CHECK: stg 1,2264(4)
; CHECK: basr 7,6
; CHECK: bcr 0,0
; CHECK: lg 7,2072(4)
; CHECK: aghi 4,224
; CHECK: b 2(7)
define hidden void @DoIt() {
entry:
%F = alloca ptr, align 8
store ptr @DoFunc, ptr %F, align 8
%0 = load ptr, ptr %F, align 8
call void @Caller(ptr noundef %0)
ret void
}
declare void @DoFunc()
declare void @Caller(ptr noundef)
; CHECK-LABEL: get_i:
; CHECK: stmg 6,8,1872(4)
; CHECK: aghi 4,-192
; CHECK: lg 1,24(5)
; CHECK: lg 2,32(5)
; CHECK: lgf 1,0(1)
; CHECK: lg 6,48(5)
; CHECK: lg 5,40(5)
; CHECK: l 8,0(2)
; CHECK: basr 7,6
; CHECK: bcr 0,0
; CHECK: ar 3,8
; CHECK: lgfr 3,3
; CHECK: lmg 7,8,2072(4)
; CHECK: aghi 4,192
; CHECK: b 2(7)
@i = external global i32, align 4
@i2 = external global i32, align 4
define signext i32 @get_i() {
entry:
%0 = load i32, ptr @i, align 4
%1 = load i32, ptr @i2, align 4
%call = call signext i32 @callout(i32 signext %1)
%add = add nsw i32 %0, %call
ret i32 %add
}
declare signext i32 @callout(i32 signext)
; CHECK: stdin#C CSECT
; CHECK: C_WSA64 CATTR ALIGN(4),FILL(0),DEFLOAD,NOTEXECUTABLE,RMODE(64),PART(stdin#S)
; CHECK: stdin#S XATTR LINKAGE(XPLINK),REFERENCE(DATA),SCOPE(SECTION)
; CHECK: .set L#DoFunc@indirect0, DoFunc
; CHECK: .indirect_symbol L#DoFunc@indirect0
; CHECK: .quad V(L#DoFunc@indirect0) * Offset 0 pointer to function descriptor DoFunc
; CHECK: .quad R(Caller) * Offset 8 function descriptor of Caller
; CHECK: .quad V(Caller)
; CHECK: .quad A(i2) * Offset 24 pointer to data symbol i2
; CHECK: .quad A(i) * Offset 32 pointer to data symbol i
; CHECK: .quad R(callout) * Offset 40 function descriptor of callout
; CHECK: .quad V(callout)