diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-12-07 00:50:54 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-12-07 00:50:54 +0000 |
commit | f91abd22be9c98abcba50952cfcd39d5264417b6 (patch) | |
tree | 997b9f4fb2ad6cf3634113001de7a348dfb9901d /lib/CodeGen | |
parent | e3d3572e282733bd7aa5ac14115ed0804174e426 (diff) |
Support vector bitcasts in the AsmPrinter. PR11495.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146001 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 8c69a3aca8..23bf602bad 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1642,6 +1642,28 @@ static void EmitGlobalConstantVector(const ConstantVector *CV, 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 @@ static void EmitGlobalConstantImpl(const Constant *CV, unsigned AddrSpace, 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. |