[ms-inline asm] Add support for the nsdialect keyword in the Bitcode

Reader/Writer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chad Rosier
2012-09-05 00:56:20 +00:00
parent 71f359a876
commit f16ae58891
3 changed files with 33 additions and 4 deletions

View File

@ -1245,7 +1245,8 @@ bool BitcodeReader::ParseConstants() {
V = ConstantExpr::getICmp(Record[3], Op0, Op1);
break;
}
case bitc::CST_CODE_INLINEASM: {
// This maintains backward compatibility, pre-'nsdialect'.
case bitc::CST_CODE_INLINEASM_OLD: {
if (Record.size() < 2) return Error("Invalid INLINEASM record");
std::string AsmStr, ConstrStr;
bool HasSideEffects = Record[0] & 1;
@ -1266,6 +1267,30 @@ bool BitcodeReader::ParseConstants() {
AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
break;
}
// This version adds support for the 'nsdialect' keyword.
case bitc::CST_CODE_INLINEASM: {
if (Record.size() < 2) return Error("Invalid INLINEASM record");
std::string AsmStr, ConstrStr;
bool HasSideEffects = Record[0] & 1;
bool IsAlignStack = (Record[0] >> 1) & 1;
unsigned AsmDialect = Record[0] >> 2;
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];
PointerType *PTy = cast<PointerType>(CurTy);
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
AsmDialect);
break;
}
case bitc::CST_CODE_BLOCKADDRESS:{
if (Record.size() < 3) return Error("Invalid CE_BLOCKADDRESS record");
Type *FnTy = getTypeByID(Record[0]);