mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-11 10:26:44 +00:00
[AIX] Lowering CPI/JTI/BA to MIR
Enable lowering of constant pool index, jump table index, and bloack address to MIR on AIX. Differential Revision: https://reviews.llvm.org/D69264
This commit is contained in:
parent
70caa1fc30
commit
5c9bdc79e1
@ -2708,9 +2708,9 @@ SDValue PPCTargetLowering::LowerConstantPool(SDValue Op,
|
||||
ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
|
||||
const Constant *C = CP->getConstVal();
|
||||
|
||||
// 64-bit SVR4 ABI code is always position-independent.
|
||||
// 64-bit SVR4 ABI and AIX ABI code are always position-independent.
|
||||
// The actual address of the GlobalValue is stored in the TOC.
|
||||
if (Subtarget.is64BitELFABI()) {
|
||||
if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI()) {
|
||||
setUsesTOCBasePtr(DAG);
|
||||
SDValue GA = DAG.getTargetConstantPool(C, PtrVT, CP->getAlignment(), 0);
|
||||
return getTOCEntry(DAG, SDLoc(CP), GA);
|
||||
@ -2784,9 +2784,9 @@ SDValue PPCTargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) const {
|
||||
EVT PtrVT = Op.getValueType();
|
||||
JumpTableSDNode *JT = cast<JumpTableSDNode>(Op);
|
||||
|
||||
// 64-bit SVR4 ABI code is always position-independent.
|
||||
// 64-bit SVR4 ABI and AIX ABI code are always position-independent.
|
||||
// The actual address of the GlobalValue is stored in the TOC.
|
||||
if (Subtarget.is64BitELFABI()) {
|
||||
if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI()) {
|
||||
setUsesTOCBasePtr(DAG);
|
||||
SDValue GA = DAG.getTargetJumpTable(JT->getIndex(), PtrVT);
|
||||
return getTOCEntry(DAG, SDLoc(JT), GA);
|
||||
@ -2813,9 +2813,9 @@ SDValue PPCTargetLowering::LowerBlockAddress(SDValue Op,
|
||||
BlockAddressSDNode *BASDN = cast<BlockAddressSDNode>(Op);
|
||||
const BlockAddress *BA = BASDN->getBlockAddress();
|
||||
|
||||
// 64-bit SVR4 ABI code is always position-independent.
|
||||
// 64-bit SVR4 ABI and AIX ABI code are always position-independent.
|
||||
// The actual BlockAddress is stored in the TOC.
|
||||
if (Subtarget.is64BitELFABI()) {
|
||||
if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI()) {
|
||||
setUsesTOCBasePtr(DAG);
|
||||
SDValue GA = DAG.getTargetBlockAddress(BA, PtrVT, BASDN->getOffset());
|
||||
return getTOCEntry(DAG, SDLoc(BASDN), GA);
|
||||
|
35
llvm/test/CodeGen/PowerPC/aix-lower-block-address.ll
Normal file
35
llvm/test/CodeGen/PowerPC/aix-lower-block-address.ll
Normal file
@ -0,0 +1,35 @@
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
|
||||
; RUN: -code-model=small -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=32SMALL-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
|
||||
; RUN: -code-model=large -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=32LARGE-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
|
||||
; RUN: -code-model=small -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=64SMALL-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
|
||||
; RUN: -code-model=large -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=64LARGE-MIR %s
|
||||
|
||||
define void @foo() {
|
||||
entry:
|
||||
%tmp = alloca i64
|
||||
br label %__here
|
||||
|
||||
__here:
|
||||
store i64 ptrtoint (i8* blockaddress(@foo, %__here) to i64), i64* %tmp
|
||||
ret void
|
||||
}
|
||||
|
||||
; 32SMALL-MIR: renamable $r[[REG1:[0-9]+]] = LWZtoc blockaddress(@foo, %ir-block.__here), $r2 :: (load 4 from got)
|
||||
|
||||
; 32LARGE-MIR: renamable $r[[REG1:[0-9]+]] = ADDIStocHA $r2, blockaddress(@foo, %ir-block.__here)
|
||||
; 32LARGE-MIR: renamable $r[[REG2:[0-9]+]] = LWZtocL blockaddress(@foo, %ir-block.__here), killed renamable $r[[REG1]], implicit $r2 :: (load 4 from got)
|
||||
|
||||
; 64SMALL-MIR: renamable $x[[REG1:[0-9]+]] = LDtocBA blockaddress(@foo, %ir-block.__here), $x2 :: (load 8 from got)
|
||||
|
||||
; 64LARGE-MIR: renamable $x[[REG1:[0-9]+]] = ADDIStocHA8 $x2, blockaddress(@foo, %ir-block.__here)
|
||||
; 64LARGE-MIR: renamable $x[[REG2:[0-9]+]] = LDtocL blockaddress(@foo, %ir-block.__here), killed renamable $x[[REG1]], implicit $x2 :: (load 8 from got)
|
34
llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
Normal file
34
llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
Normal file
@ -0,0 +1,34 @@
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
|
||||
; RUN: -code-model=small -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=32SMALL-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
|
||||
; RUN: -code-model=large -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=32LARGE-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
|
||||
; RUN: -code-model=small -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=64SMALL-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
|
||||
; RUN: -code-model=large -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=64LARGE-MIR %s
|
||||
|
||||
define float @test_float() {
|
||||
entry:
|
||||
ret float 5.500000e+00
|
||||
}
|
||||
|
||||
; 32SMALL-MIR: renamable $r[[REG1:[0-9]+]] = LWZtoc %const.0, $r2 :: (load 4 from got)
|
||||
; 32SMALL-MIR: renamable $f[[REG2:[0-9]+]] = LFS 0, killed renamable $r[[REG1]] :: (load 4 from constant-pool)
|
||||
|
||||
; 32LARGE-MIR: renamable $r[[REG1:[0-9]+]] = ADDIStocHA $r2, %const.0
|
||||
; 32LARGE-MIR: renamable $r[[REG2:[0-9]+]] = LWZtocL %const.0, killed renamable $r[[REG1]], implicit $r2 :: (load 4 from got)
|
||||
; 32LARGE-MIR: renamable $f[[REG3:[0-9]+]] = LFS 0, killed renamable $r[[REG2]] :: (load 4 from constant-pool)
|
||||
|
||||
; 64SMALL-MIR: renamable $x[[REG1:[0-9]+]] = LDtocCPT %const.0, $x2 :: (load 8 from got)
|
||||
; 64SMALL-MIR: renamable $f[[REG2:[0-9]+]] = LFS 0, killed renamable $x[[REG1]] :: (load 4 from constant-pool)
|
||||
|
||||
; 64LARGE-MIR: renamable $x[[REG1:[0-9]+]] = ADDIStocHA8 $x2, %const.0
|
||||
; 64LARGE-MIR: renamable $x[[REG2:[0-9]+]] = LDtocL %const.0, killed renamable $x[[REG1]], implicit $x2 :: (load 8 from got)
|
||||
; 64LARGE-MIR: renamable $f[[REG3:[0-9]+]] = LFS 0, killed renamable $x[[REG2]] :: (load 4 from constant-pool)
|
63
llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
Normal file
63
llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
Normal file
@ -0,0 +1,63 @@
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
|
||||
; RUN: -code-model=small -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=32SMALL-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff \
|
||||
; RUN: -code-model=large -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=32LARGE-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
|
||||
; RUN: -code-model=small -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=64SMALL-MIR %s
|
||||
|
||||
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff \
|
||||
; RUN: -code-model=large -stop-after=machine-cp < %s | FileCheck \
|
||||
; RUN: --check-prefix=64LARGE-MIR %s
|
||||
|
||||
define i32 @jump_table(i32 %a) {
|
||||
entry:
|
||||
switch i32 %a, label %sw.epilog [
|
||||
i32 1, label %sw.bb
|
||||
i32 2, label %sw.bb1
|
||||
i32 3, label %sw.bb2
|
||||
i32 4, label %sw.bb3
|
||||
]
|
||||
|
||||
sw.bb:
|
||||
tail call void asm sideeffect "", ""()
|
||||
br label %sw.epilog
|
||||
|
||||
sw.bb1:
|
||||
tail call void asm sideeffect "", ""()
|
||||
br label %sw.epilog
|
||||
|
||||
sw.bb2:
|
||||
tail call void asm sideeffect "", ""()
|
||||
br label %sw.epilog
|
||||
|
||||
sw.bb3:
|
||||
tail call void asm sideeffect "", ""()
|
||||
br label %sw.epilog
|
||||
|
||||
sw.epilog:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
|
||||
; 32SMALL-MIR: renamable $r[[REG1:[0-9]+]] = LWZtoc %jump-table.0, $r2 :: (load 4 from got)
|
||||
; 32SMALL-MIR: renamable $r[[REG3:[0-9]+]] = RLWINM killed renamable $r[[REG2:[0-9]+]], 2, 0, 29
|
||||
; 32SMALL-MIR: renamable $r[[REG4:[0-9]+]] = LWZX killed renamable $r[[REG3]], killed renamable $r[[REG1]] :: (load 4 from jump-table)
|
||||
|
||||
; 32LARGE-MIR: renamable $r[[REG1:[0-9]+]] = ADDIStocHA $r2, %jump-table.0
|
||||
; 32LARGE-MIR: renamable $r[[REG2:[0-9]+]] = LWZtocL %jump-table.0, killed renamable $r[[REG1]], implicit $r2 :: (load 4 from got)
|
||||
; 32LARGE-MIR: renamable $r[[REG4:[0-9]+]] = RLWINM killed renamable $r[[REG3:[0-9]+]], 2, 0, 29
|
||||
; 32LARGE-MIR: renamable $r[[REG5:[0-9]+]] = LWZX killed renamable $r[[REG4]], killed renamable $r[[REG2]] :: (load 4 from jump-table)
|
||||
|
||||
; 64SMALL-MIR: renamable $x[[REG1:[0-9]+]] = LDtocJTI %jump-table.0, $x2 :: (load 8 from got)
|
||||
; 64SMALL-MIR: renamable $x[[REG3:[0-9]+]] = RLDIC killed renamable $x[[REG2:[0-9]+]], 2, 30
|
||||
; 64SMALL-MIR: renamable $x[[REG4:[0-9]+]] = LWAX killed renamable $x[[REG3]], renamable $x[[REG1]] :: (load 4 from jump-table)
|
||||
|
||||
; 64LARGE-MIR: renamable $x[[REG1:[0-9]+]] = ADDIStocHA8 $x2, %jump-table.0
|
||||
; 64LARGE-MIR: renamable $x[[REG2:[0-9]+]] = LDtocL %jump-table.0, killed renamable $x[[REG1]], implicit $x2 :: (load 8 from got)
|
||||
; 64LARGE-MIR: renamable $x[[REG4:[0-9]+]] = RLDIC killed renamable $x[[REG3:[0-9]+]], 2, 30
|
||||
; 64LARGE-MIR: renamable $x[[REG5:[0-9]+]] = LWAX killed renamable $x[[REG4]], killed renamable $x[[REG2]] :: (load 4 from jump-table)
|
Loading…
x
Reference in New Issue
Block a user