[PATCH] D157950: [RISCV][GISel] Mark G_GLOBAL_VALUE as legal.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 22:55:49 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: nitinjohnraj, arsenm, asb.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: wangpc, eopXD, MaskRay, wdng.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157950
Files:
llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-global.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-global.mir
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-global.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv64/legalize-global.mir
@@ -0,0 +1,33 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - | FileCheck %s
+
+--- |
+ @var = global i32 0
+
+ define ptr @test_global() {
+ ret ptr @var
+ }
+
+...
+---
+name: test_global
+alignment: 4
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: _ }
+frameInfo:
+ maxAlignment: 1
+machineFunctionInfo:
+ varArgsFrameIndex: 0
+ varArgsSaveSize: 0
+body: |
+ bb.1 (%ir-block.0):
+ ; CHECK-LABEL: name: test_global
+ ; CHECK: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var
+ ; CHECK-NEXT: $x10 = COPY [[GV]](p0)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(p0) = G_GLOBAL_VALUE @var
+ $x10 = COPY %0(p0)
+ PseudoRET implicit $x10
+
+...
Index: llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-global.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/GlobalISel/legalizer/rv32/legalize-global.mir
@@ -0,0 +1,33 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - | FileCheck %s
+
+--- |
+ @var = global i32 0
+
+ define ptr @test_global() {
+ ret ptr @var
+ }
+
+...
+---
+name: test_global
+alignment: 4
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: _ }
+frameInfo:
+ maxAlignment: 1
+machineFunctionInfo:
+ varArgsFrameIndex: 0
+ varArgsSaveSize: 0
+body: |
+ bb.1 (%ir-block.0):
+ ; CHECK-LABEL: name: test_global
+ ; CHECK: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var
+ ; CHECK-NEXT: $x10 = COPY [[GV]](p0)
+ ; CHECK-NEXT: PseudoRET implicit $x10
+ %0:_(p0) = G_GLOBAL_VALUE @var
+ $x10 = COPY %0(p0)
+ PseudoRET implicit $x10
+
+...
Index: llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -89,5 +89,8 @@
.widenScalarToNextPow2(0)
.clampScalar(0, XLenLLT, XLenLLT);
+ getActionDefinitionsBuilder(G_GLOBAL_VALUE)
+ .legalFor({p0});
+
getLegacyLegalizerInfo().computeTables();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157950.550195.patch
Type: text/x-patch
Size: 2522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230815/5e67b3c3/attachment.bin>
More information about the llvm-commits
mailing list