[llvm] r278423 - GlobalISel: support 'null' constant in translation.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 14:40:55 PDT 2016
Author: tnorthover
Date: Thu Aug 11 16:40:55 2016
New Revision: 278423
URL: http://llvm.org/viewvc/llvm-project?rev=278423&view=rev
Log:
GlobalISel: support 'null' constant in translation.
It's sharing the integer G_CONSTANT for now since I don't *think* it creates
any ambiguity (even on weird archs). If that turns out wrong we can create a
G_PTRCONSTANT or something.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=278423&r1=278422&r2=278423&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Thu Aug 11 16:40:55 2016
@@ -296,6 +296,10 @@ bool IRTranslator::translate(const Const
EntryBuilder.buildConstant(LLT{*CI->getType()}, Reg, CI->getZExtValue());
else if (isa<UndefValue>(C))
EntryBuilder.buildInstr(TargetOpcode::IMPLICIT_DEF).addDef(Reg);
+ else if (isa<ConstantPointerNull>(C))
+ EntryBuilder.buildInstr(TargetOpcode::G_CONSTANT, LLT{*C.getType()})
+ .addDef(Reg)
+ .addImm(0);
else if (auto CE = dyn_cast<ConstantExpr>(&C)) {
switch(CE->getOpcode()) {
#define HANDLE_INST(NUM, OPCODE, CLASS) \
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll?rev=278423&r1=278422&r2=278423&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll Thu Aug 11 16:40:55 2016
@@ -458,3 +458,10 @@ define i32 @test_ashr(i32 %arg1, i32 %ar
%res = ashr i32 %arg1, %arg2
ret i32 %res
}
+
+; CHECK-LABEL: name: test_constant_null
+; CHECK: [[NULL:%[0-9]+]](64) = G_CONSTANT p0 0
+; CHECK: %x0 = COPY [[NULL]]
+define i8* @test_constant_null() {
+ ret i8* null
+}
More information about the llvm-commits
mailing list