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
This commit is contained in:
Chris Lattner
2006-01-25 23:08:15 +00:00
parent 5f8f0e219d
commit 3bc5a60b80
6 changed files with 74 additions and 34 deletions

View File

@ -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));
}
}