[llvm] r278174 - GlobalISel: support 'undef' constant.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 16:01:30 PDT 2016
Author: tnorthover
Date: Tue Aug 9 18:01:30 2016
New Revision: 278174
URL: http://llvm.org/viewvc/llvm-project?rev=278174&view=rev
Log:
GlobalISel: support 'undef' constant.
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=278174&r1=278173&r2=278174&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Tue Aug 9 18:01:30 2016
@@ -318,12 +318,14 @@ bool IRTranslator::translate(const Instr
}
bool IRTranslator::translate(const Constant &C, unsigned Reg) {
- if (auto CI = dyn_cast<ConstantInt>(&C)) {
+ if (auto CI = dyn_cast<ConstantInt>(&C))
EntryBuilder.buildConstant(LLT{*CI->getType()}, Reg, CI->getZExtValue());
- return true;
- }
+ else if (isa<UndefValue>(C))
+ EntryBuilder.buildInstr(TargetOpcode::IMPLICIT_DEF).addDef(Reg);
+ else
+ llvm_unreachable("unhandled constant kind");
- llvm_unreachable("unhandled constant kind");
+ return true;
}
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=278174&r1=278173&r2=278174&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll Tue Aug 9 18:01:30 2016
@@ -363,3 +363,10 @@ define i32 @constant_int_start() {
%res = add i32 2, 42
ret i32 %res
}
+
+; CHECK-LABEL: name: test_undef
+; CHECK: [[UNDEF:%[0-9]+]](32) = IMPLICIT_DEF
+; CHECK: %w0 = COPY [[UNDEF]]
+define i32 @test_undef() {
+ ret i32 undef
+}
More information about the llvm-commits
mailing list