mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
implement reading/writing of inlineasm objects
llvm-svn: 36827
This commit is contained in:
parent
c9ca38fedf
commit
7eb319ab65
@ -15,6 +15,7 @@
|
||||
#include "BitcodeReader.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ParameterAttributes.h"
|
||||
@ -759,6 +760,26 @@ bool BitcodeReader::ParseConstants() {
|
||||
V = ConstantExpr::getICmp(Record[3], Op0, Op1);
|
||||
break;
|
||||
}
|
||||
case bitc::CST_CODE_INLINEASM: {
|
||||
if (Record.size() < 2) return Error("Invalid INLINEASM record");
|
||||
std::string AsmStr, ConstrStr;
|
||||
bool HasSideEffects = Record[0];
|
||||
unsigned AsmStrSize = Record[1];
|
||||
if (2+AsmStrSize >= Record.size())
|
||||
return Error("Invalid INLINEASM record");
|
||||
unsigned ConstStrSize = Record[2+AsmStrSize];
|
||||
if (3+AsmStrSize+ConstStrSize > Record.size())
|
||||
return Error("Invalid INLINEASM record");
|
||||
|
||||
for (unsigned i = 0; i != AsmStrSize; ++i)
|
||||
AsmStr += (char)Record[2+i];
|
||||
for (unsigned i = 0; i != ConstStrSize; ++i)
|
||||
ConstrStr += (char)Record[3+AsmStrSize+i];
|
||||
const PointerType *PTy = cast<PointerType>(CurTy);
|
||||
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
|
||||
AsmStr, ConstrStr, HasSideEffects);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ValueList.AssignValue(V, NextCstNo);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "ValueEnumerator.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ParameterAttributes.h"
|
||||
@ -446,9 +447,6 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
|
||||
CString6Abbrev = Stream.EmitAbbrev(Abbv);
|
||||
}
|
||||
|
||||
// FIXME: Install and use abbrevs to reduce size. Install them globally so
|
||||
// they don't need to be reemitted for each function body.
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
|
||||
const ValueEnumerator::ValueList &Vals = VE.getValues();
|
||||
@ -465,7 +463,21 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
|
||||
}
|
||||
|
||||
if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
|
||||
assert(0 && IA && "FIXME: Inline asm writing unimp!");
|
||||
Record.push_back(unsigned(IA->hasSideEffects()));
|
||||
|
||||
// Add the asm string.
|
||||
const std::string &AsmStr = IA->getAsmString();
|
||||
Record.push_back(AsmStr.size());
|
||||
for (unsigned i = 0, e = AsmStr.size(); i != e; ++i)
|
||||
Record.push_back(AsmStr[i]);
|
||||
|
||||
// Add the constraint string.
|
||||
const std::string &ConstraintStr = IA->getConstraintString();
|
||||
Record.push_back(ConstraintStr.size());
|
||||
for (unsigned i = 0, e = ConstraintStr.size(); i != e; ++i)
|
||||
Record.push_back(ConstraintStr[i]);
|
||||
Stream.EmitRecord(bitc::CST_CODE_INLINEASM, Record);
|
||||
Record.clear();
|
||||
continue;
|
||||
}
|
||||
const Constant *C = cast<Constant>(V);
|
||||
@ -894,8 +906,6 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
|
||||
Stream.EmitRecord(bitc::FUNC_CODE_DECLAREBLOCKS, Vals);
|
||||
Vals.clear();
|
||||
|
||||
// FIXME: Function attributes?
|
||||
|
||||
// If there are function-local constants, emit them now.
|
||||
unsigned CstStart, CstEnd;
|
||||
VE.getFunctionConstantRange(CstStart, CstEnd);
|
||||
|
Loading…
Reference in New Issue
Block a user