diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-25 23:08:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-25 23:08:15 +0000 |
commit | 3bc5a60b80dc27868a5c6f14358a068a110e6ded (patch) | |
tree | f6a1ecf0acf41d0052cb376cca6fbe2b609422ea /lib/Bytecode/Writer/Writer.cpp | |
parent | 5f8f0e219dce9f3defd62a2f8f4c4c7f3e88e8c0 (diff) |
add bc reader/writer support for inline asm
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Writer/Writer.cpp')
-rw-r--r-- | lib/Bytecode/Writer/Writer.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index bfbce91c56..80abcacee9 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -22,6 +22,7 @@ #include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/InlineAsm.h" #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" @@ -389,6 +390,19 @@ void BytecodeWriter::outputConstant(const Constant *CPV) { return; } +/// outputInlineAsm - InlineAsm's get emitted to the constant pool, so they can +/// be shared by multiple uses. +void BytecodeWriter::outputInlineAsm(const InlineAsm *IA) { + // Output a marker, so we know when we have one one parsing the constant pool. + // Note that this encoding is 5 bytes: not very efficient for a marker. Since + // unique inline asms are rare, this should hardly matter. + output_vbr(~0U); + + output(IA->getAsmString()); + output(IA->getConstraintString()); + output_vbr(unsigned(IA->hasSideEffects())); +} + void BytecodeWriter::outputConstantStrings() { SlotCalculator::string_iterator I = Table.string_begin(); SlotCalculator::string_iterator E = Table.string_end(); @@ -847,7 +861,8 @@ void BytecodeWriter::outputConstantsInPlane(const std::vector<const Value*> /*empty*/; unsigned NC = ValNo; // Number of constants - for (; NC < Plane.size() && (isa<Constant>(Plane[NC])); NC++) + for (; NC < Plane.size() && (isa<Constant>(Plane[NC]) || + isa<InlineAsm>(Plane[NC])); NC++) /*empty*/; NC -= ValNo; // Convert from index into count if (NC == 0) return; // Skip empty type planes... @@ -866,9 +881,10 @@ void BytecodeWriter::outputConstantsInPlane(const std::vector<const Value*> for (unsigned i = ValNo; i < ValNo+NC; ++i) { const Value *V = Plane[i]; - if (const Constant *C = dyn_cast<Constant>(V)) { + if (const Constant *C = dyn_cast<Constant>(V)) outputConstant(C); - } + else + outputInlineAsm(cast<InlineAsm>(V)); } } |