[llvm-commits] [llvm] r146001 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2011-12-06-BitcastVectorGlobal.ll
Eli Friedman
eli.friedman at gmail.com
Tue Dec 6 16:50:54 PST 2011
Author: efriedma
Date: Tue Dec 6 18:50:54 2011
New Revision: 146001
URL: http://llvm.org/viewvc/llvm-project?rev=146001&view=rev
Log:
Support vector bitcasts in the AsmPrinter. PR11495.
Added:
llvm/trunk/test/CodeGen/X86/2011-12-06-BitcastVectorGlobal.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=146001&r1=146000&r2=146001&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Dec 6 18:50:54 2011
@@ -1642,6 +1642,28 @@
AP.OutStreamer.EmitZeros(Padding, AddrSpace);
}
+static void LowerVectorConstant(const Constant *CV, unsigned AddrSpace,
+ AsmPrinter &AP) {
+ // Look through bitcasts
+ if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV))
+ if (CE->getOpcode() == Instruction::BitCast)
+ CV = CE->getOperand(0);
+
+ if (const ConstantVector *V = dyn_cast<ConstantVector>(CV))
+ return EmitGlobalConstantVector(V, AddrSpace, AP);
+
+ // If we get here, we're stuck; report the problem to the user.
+ // FIXME: Are there any other useful tricks for vectors?
+ {
+ std::string S;
+ raw_string_ostream OS(S);
+ OS << "Unsupported vector expression in static initializer: ";
+ WriteAsOperand(OS, CV, /*PrintType=*/false,
+ !AP.MF ? 0 : AP.MF->getFunction()->getParent());
+ report_fatal_error(OS.str());
+ }
+}
+
static void EmitGlobalConstantStruct(const ConstantStruct *CS,
unsigned AddrSpace, AsmPrinter &AP) {
// Print the fields in successive locations. Pad to align if needed!
@@ -1796,8 +1818,8 @@
return;
}
- if (const ConstantVector *V = dyn_cast<ConstantVector>(CV))
- return EmitGlobalConstantVector(V, AddrSpace, AP);
+ if (CV->getType()->isVectorTy())
+ return LowerVectorConstant(CV, AddrSpace, AP);
// Otherwise, it must be a ConstantExpr. Lower it to an MCExpr, then emit it
// thread the streamer with EmitValue.
Added: llvm/trunk/test/CodeGen/X86/2011-12-06-BitcastVectorGlobal.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2011-12-06-BitcastVectorGlobal.ll?rev=146001&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2011-12-06-BitcastVectorGlobal.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2011-12-06-BitcastVectorGlobal.ll Tue Dec 6 18:50:54 2011
@@ -0,0 +1,5 @@
+; RUN: llc < %s -march=x86-64 | FileCheck %s
+; PR11495
+
+; CHECK: 1311768467463790320
+ at v = global <2 x float> bitcast (<1 x i64> <i64 1311768467463790320> to <2 x float>), align 8
More information about the llvm-commits
mailing list