llvm.org GIT mirror llvm / 2bce93a
implement reading/writing of inlineasm objects git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36827 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
2 changed file(s) with 37 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
1414 #include "BitcodeReader.h"
1515 #include "llvm/Constants.h"
1616 #include "llvm/DerivedTypes.h"
17 #include "llvm/InlineAsm.h"
1718 #include "llvm/Instructions.h"
1819 #include "llvm/Module.h"
1920 #include "llvm/ParameterAttributes.h"
756757 V = ConstantExpr::getFCmp(Record[3], Op0, Op1);
757758 else
758759 V = ConstantExpr::getICmp(Record[3], Op0, Op1);
760 break;
761 }
762 case bitc::CST_CODE_INLINEASM: {
763 if (Record.size() < 2) return Error("Invalid INLINEASM record");
764 std::string AsmStr, ConstrStr;
765 bool HasSideEffects = Record[0];
766 unsigned AsmStrSize = Record[1];
767 if (2+AsmStrSize >= Record.size())
768 return Error("Invalid INLINEASM record");
769 unsigned ConstStrSize = Record[2+AsmStrSize];
770 if (3+AsmStrSize+ConstStrSize > Record.size())
771 return Error("Invalid INLINEASM record");
772
773 for (unsigned i = 0; i != AsmStrSize; ++i)
774 AsmStr += (char)Record[2+i];
775 for (unsigned i = 0; i != ConstStrSize; ++i)
776 ConstrStr += (char)Record[3+AsmStrSize+i];
777 const PointerType *PTy = cast(CurTy);
778 V = InlineAsm::get(cast(PTy->getElementType()),
779 AsmStr, ConstrStr, HasSideEffects);
759780 break;
760781 }
761782 }
1616 #include "ValueEnumerator.h"
1717 #include "llvm/Constants.h"
1818 #include "llvm/DerivedTypes.h"
19 #include "llvm/InlineAsm.h"
1920 #include "llvm/Instructions.h"
2021 #include "llvm/Module.h"
2122 #include "llvm/ParameterAttributes.h"
445446 CString6Abbrev = Stream.EmitAbbrev(Abbv);
446447 }
447448
448 // FIXME: Install and use abbrevs to reduce size. Install them globally so
449 // they don't need to be reemitted for each function body.
450
451449 SmallVector Record;
452450
453451 const ValueEnumerator::ValueList &Vals = VE.getValues();
464462 }
465463
466464 if (const InlineAsm *IA = dyn_cast(V)) {
467 assert(0 && IA && "FIXME: Inline asm writing unimp!");
465 Record.push_back(unsigned(IA->hasSideEffects()));
466
467 // Add the asm string.
468 const std::string &AsmStr = IA->getAsmString();
469 Record.push_back(AsmStr.size());
470 for (unsigned i = 0, e = AsmStr.size(); i != e; ++i)
471 Record.push_back(AsmStr[i]);
472
473 // Add the constraint string.
474 const std::string &ConstraintStr = IA->getConstraintString();
475 Record.push_back(ConstraintStr.size());
476 for (unsigned i = 0, e = ConstraintStr.size(); i != e; ++i)
477 Record.push_back(ConstraintStr[i]);
478 Stream.EmitRecord(bitc::CST_CODE_INLINEASM, Record);
479 Record.clear();
468480 continue;
469481 }
470482 const Constant *C = cast(V);
893905 Stream.EmitRecord(bitc::FUNC_CODE_DECLAREBLOCKS, Vals);
894906 Vals.clear();
895907
896 // FIXME: Function attributes?
897
898908 // If there are function-local constants, emit them now.
899909 unsigned CstStart, CstEnd;
900910 VE.getFunctionConstantRange(CstStart, CstEnd);