CodeEmitterGen.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. //===- CodeEmitterGen.cpp - Code Emitter Generator ------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // CodeEmitterGen uses the descriptions of instructions and their fields to
  10. // construct an automated code emitter: a function that, given a MachineInstr,
  11. // returns the (currently, 32-bit unsigned) value of the instruction.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #include "CodeGenInstruction.h"
  15. #include "CodeGenTarget.h"
  16. #include "SubtargetFeatureInfo.h"
  17. #include "Types.h"
  18. #include "VarLenCodeEmitterGen.h"
  19. #include "llvm/ADT/APInt.h"
  20. #include "llvm/ADT/ArrayRef.h"
  21. #include "llvm/ADT/StringExtras.h"
  22. #include "llvm/Support/Casting.h"
  23. #include "llvm/Support/raw_ostream.h"
  24. #include "llvm/TableGen/Error.h"
  25. #include "llvm/TableGen/Record.h"
  26. #include "llvm/TableGen/TableGenBackend.h"
  27. #include <cstdint>
  28. #include <map>
  29. #include <set>
  30. #include <string>
  31. #include <utility>
  32. #include <vector>
  33. using namespace llvm;
  34. namespace {
  35. class CodeEmitterGen {
  36. RecordKeeper &Records;
  37. public:
  38. CodeEmitterGen(RecordKeeper &R) : Records(R) {}
  39. void run(raw_ostream &o);
  40. private:
  41. int getVariableBit(const std::string &VarName, BitsInit *BI, int bit);
  42. std::string getInstructionCase(Record *R, CodeGenTarget &Target);
  43. std::string getInstructionCaseForEncoding(Record *R, Record *EncodingDef,
  44. CodeGenTarget &Target);
  45. bool addCodeToMergeInOperand(Record *R, BitsInit *BI,
  46. const std::string &VarName, unsigned &NumberedOp,
  47. std::set<unsigned> &NamedOpIndices,
  48. std::string &Case, CodeGenTarget &Target);
  49. void emitInstructionBaseValues(
  50. raw_ostream &o, ArrayRef<const CodeGenInstruction *> NumberedInstructions,
  51. CodeGenTarget &Target, int HwMode = -1);
  52. unsigned BitWidth;
  53. bool UseAPInt;
  54. };
  55. // If the VarBitInit at position 'bit' matches the specified variable then
  56. // return the variable bit position. Otherwise return -1.
  57. int CodeEmitterGen::getVariableBit(const std::string &VarName,
  58. BitsInit *BI, int bit) {
  59. if (VarBitInit *VBI = dyn_cast<VarBitInit>(BI->getBit(bit))) {
  60. if (VarInit *VI = dyn_cast<VarInit>(VBI->getBitVar()))
  61. if (VI->getName() == VarName)
  62. return VBI->getBitNum();
  63. } else if (VarInit *VI = dyn_cast<VarInit>(BI->getBit(bit))) {
  64. if (VI->getName() == VarName)
  65. return 0;
  66. }
  67. return -1;
  68. }
  69. // Returns true if it succeeds, false if an error.
  70. bool CodeEmitterGen::addCodeToMergeInOperand(Record *R, BitsInit *BI,
  71. const std::string &VarName,
  72. unsigned &NumberedOp,
  73. std::set<unsigned> &NamedOpIndices,
  74. std::string &Case,
  75. CodeGenTarget &Target) {
  76. CodeGenInstruction &CGI = Target.getInstruction(R);
  77. // Determine if VarName actually contributes to the Inst encoding.
  78. int bit = BI->getNumBits()-1;
  79. // Scan for a bit that this contributed to.
  80. for (; bit >= 0; ) {
  81. if (getVariableBit(VarName, BI, bit) != -1)
  82. break;
  83. --bit;
  84. }
  85. // If we found no bits, ignore this value, otherwise emit the call to get the
  86. // operand encoding.
  87. if (bit < 0)
  88. return true;
  89. // If the operand matches by name, reference according to that
  90. // operand number. Non-matching operands are assumed to be in
  91. // order.
  92. unsigned OpIdx;
  93. std::pair<unsigned, unsigned> SubOp;
  94. if (CGI.Operands.hasSubOperandAlias(VarName, SubOp)) {
  95. OpIdx = CGI.Operands[SubOp.first].MIOperandNo + SubOp.second;
  96. } else if (CGI.Operands.hasOperandNamed(VarName, OpIdx)) {
  97. // Get the machine operand number for the indicated operand.
  98. OpIdx = CGI.Operands[OpIdx].MIOperandNo;
  99. } else {
  100. // Fall back to positional lookup. By default, we now disable positional
  101. // lookup (and print an error, below), but even so, we'll do the lookup to
  102. // help print a helpful diagnostic message.
  103. //
  104. // TODO: When we remove useDeprecatedPositionallyEncodedOperands, delete all
  105. // this code, just leaving a "no operand named X in record Y" error.
  106. unsigned NumberOps = CGI.Operands.size();
  107. /// If this operand is not supposed to be emitted by the
  108. /// generated emitter, skip it.
  109. while (NumberedOp < NumberOps &&
  110. (CGI.Operands.isFlatOperandNotEmitted(NumberedOp) ||
  111. (!NamedOpIndices.empty() && NamedOpIndices.count(
  112. CGI.Operands.getSubOperandNumber(NumberedOp).first)))) {
  113. ++NumberedOp;
  114. }
  115. if (NumberedOp >=
  116. CGI.Operands.back().MIOperandNo + CGI.Operands.back().MINumOperands) {
  117. if (!Target.getInstructionSet()->getValueAsBit(
  118. "useDeprecatedPositionallyEncodedOperands")) {
  119. PrintError(R, Twine("No operand named ") + VarName + " in record " +
  120. R->getName() +
  121. " (would've given 'too few operands' error with "
  122. "useDeprecatedPositionallyEncodedOperands=true)");
  123. } else {
  124. PrintError(R, "Too few operands in record " + R->getName() +
  125. " (no match for variable " + VarName + ")");
  126. }
  127. return false;
  128. }
  129. OpIdx = NumberedOp++;
  130. if (!Target.getInstructionSet()->getValueAsBit(
  131. "useDeprecatedPositionallyEncodedOperands")) {
  132. std::pair<unsigned, unsigned> SO =
  133. CGI.Operands.getSubOperandNumber(OpIdx);
  134. std::string OpName = CGI.Operands[SO.first].Name;
  135. PrintError(R, Twine("No operand named ") + VarName + " in record " +
  136. R->getName() + " (would've used positional operand #" +
  137. Twine(SO.first) + " ('" + OpName + "') sub-op #" +
  138. Twine(SO.second) +
  139. " with useDeprecatedPositionallyEncodedOperands=true)");
  140. return false;
  141. }
  142. }
  143. if (CGI.Operands.isFlatOperandNotEmitted(OpIdx)) {
  144. PrintError(R, "Operand " + VarName + " used but also marked as not emitted!");
  145. return false;
  146. }
  147. std::pair<unsigned, unsigned> SO = CGI.Operands.getSubOperandNumber(OpIdx);
  148. std::string &EncoderMethodName =
  149. CGI.Operands[SO.first].EncoderMethodNames[SO.second];
  150. if (UseAPInt)
  151. Case += " op.clearAllBits();\n";
  152. Case += " // op: " + VarName + "\n";
  153. // If the source operand has a custom encoder, use it.
  154. if (!EncoderMethodName.empty()) {
  155. if (UseAPInt) {
  156. Case += " " + EncoderMethodName + "(MI, " + utostr(OpIdx);
  157. Case += ", op";
  158. } else {
  159. Case += " op = " + EncoderMethodName + "(MI, " + utostr(OpIdx);
  160. }
  161. Case += ", Fixups, STI);\n";
  162. } else {
  163. if (UseAPInt) {
  164. Case += " getMachineOpValue(MI, MI.getOperand(" + utostr(OpIdx) + ")";
  165. Case += ", op, Fixups, STI";
  166. } else {
  167. Case += " op = getMachineOpValue(MI, MI.getOperand(" + utostr(OpIdx) + ")";
  168. Case += ", Fixups, STI";
  169. }
  170. Case += ");\n";
  171. }
  172. // Precalculate the number of lits this variable contributes to in the
  173. // operand. If there is a single lit (consecutive range of bits) we can use a
  174. // destructive sequence on APInt that reduces memory allocations.
  175. int numOperandLits = 0;
  176. for (int tmpBit = bit; tmpBit >= 0;) {
  177. int varBit = getVariableBit(VarName, BI, tmpBit);
  178. // If this bit isn't from a variable, skip it.
  179. if (varBit == -1) {
  180. --tmpBit;
  181. continue;
  182. }
  183. // Figure out the consecutive range of bits covered by this operand, in
  184. // order to generate better encoding code.
  185. int beginVarBit = varBit;
  186. int N = 1;
  187. for (--tmpBit; tmpBit >= 0;) {
  188. varBit = getVariableBit(VarName, BI, tmpBit);
  189. if (varBit == -1 || varBit != (beginVarBit - N))
  190. break;
  191. ++N;
  192. --tmpBit;
  193. }
  194. ++numOperandLits;
  195. }
  196. for (; bit >= 0; ) {
  197. int varBit = getVariableBit(VarName, BI, bit);
  198. // If this bit isn't from a variable, skip it.
  199. if (varBit == -1) {
  200. --bit;
  201. continue;
  202. }
  203. // Figure out the consecutive range of bits covered by this operand, in
  204. // order to generate better encoding code.
  205. int beginInstBit = bit;
  206. int beginVarBit = varBit;
  207. int N = 1;
  208. for (--bit; bit >= 0;) {
  209. varBit = getVariableBit(VarName, BI, bit);
  210. if (varBit == -1 || varBit != (beginVarBit - N)) break;
  211. ++N;
  212. --bit;
  213. }
  214. std::string maskStr;
  215. int opShift;
  216. unsigned loBit = beginVarBit - N + 1;
  217. unsigned hiBit = loBit + N;
  218. unsigned loInstBit = beginInstBit - N + 1;
  219. if (UseAPInt) {
  220. std::string extractStr;
  221. if (N >= 64) {
  222. extractStr = "op.extractBits(" + itostr(hiBit - loBit) + ", " +
  223. itostr(loBit) + ")";
  224. Case += " Value.insertBits(" + extractStr + ", " +
  225. itostr(loInstBit) + ");\n";
  226. } else {
  227. extractStr = "op.extractBitsAsZExtValue(" + itostr(hiBit - loBit) +
  228. ", " + itostr(loBit) + ")";
  229. Case += " Value.insertBits(" + extractStr + ", " +
  230. itostr(loInstBit) + ", " + itostr(hiBit - loBit) + ");\n";
  231. }
  232. } else {
  233. uint64_t opMask = ~(uint64_t)0 >> (64 - N);
  234. opShift = beginVarBit - N + 1;
  235. opMask <<= opShift;
  236. maskStr = "UINT64_C(" + utostr(opMask) + ")";
  237. opShift = beginInstBit - beginVarBit;
  238. if (numOperandLits == 1) {
  239. Case += " op &= " + maskStr + ";\n";
  240. if (opShift > 0) {
  241. Case += " op <<= " + itostr(opShift) + ";\n";
  242. } else if (opShift < 0) {
  243. Case += " op >>= " + itostr(-opShift) + ";\n";
  244. }
  245. Case += " Value |= op;\n";
  246. } else {
  247. if (opShift > 0) {
  248. Case += " Value |= (op & " + maskStr + ") << " +
  249. itostr(opShift) + ";\n";
  250. } else if (opShift < 0) {
  251. Case += " Value |= (op & " + maskStr + ") >> " +
  252. itostr(-opShift) + ";\n";
  253. } else {
  254. Case += " Value |= (op & " + maskStr + ");\n";
  255. }
  256. }
  257. }
  258. }
  259. return true;
  260. }
  261. std::string CodeEmitterGen::getInstructionCase(Record *R,
  262. CodeGenTarget &Target) {
  263. std::string Case;
  264. if (const RecordVal *RV = R->getValue("EncodingInfos")) {
  265. if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
  266. const CodeGenHwModes &HWM = Target.getHwModes();
  267. EncodingInfoByHwMode EBM(DI->getDef(), HWM);
  268. Case += " switch (HwMode) {\n";
  269. Case += " default: llvm_unreachable(\"Unhandled HwMode\");\n";
  270. for (auto &KV : EBM) {
  271. Case += " case " + itostr(KV.first) + ": {\n";
  272. Case += getInstructionCaseForEncoding(R, KV.second, Target);
  273. Case += " break;\n";
  274. Case += " }\n";
  275. }
  276. Case += " }\n";
  277. return Case;
  278. }
  279. }
  280. return getInstructionCaseForEncoding(R, R, Target);
  281. }
  282. std::string CodeEmitterGen::getInstructionCaseForEncoding(Record *R, Record *EncodingDef,
  283. CodeGenTarget &Target) {
  284. std::string Case;
  285. BitsInit *BI = EncodingDef->getValueAsBitsInit("Inst");
  286. unsigned NumberedOp = 0;
  287. std::set<unsigned> NamedOpIndices;
  288. // Collect the set of operand indices that might correspond to named
  289. // operand, and skip these when assigning operands based on position.
  290. if (Target.getInstructionSet()->
  291. getValueAsBit("noNamedPositionallyEncodedOperands")) {
  292. CodeGenInstruction &CGI = Target.getInstruction(R);
  293. for (const RecordVal &RV : R->getValues()) {
  294. unsigned OpIdx;
  295. if (!CGI.Operands.hasOperandNamed(RV.getName(), OpIdx))
  296. continue;
  297. NamedOpIndices.insert(OpIdx);
  298. }
  299. }
  300. // Loop over all of the fields in the instruction, determining which are the
  301. // operands to the instruction.
  302. bool Success = true;
  303. for (const RecordVal &RV : EncodingDef->getValues()) {
  304. // Ignore fixed fields in the record, we're looking for values like:
  305. // bits<5> RST = { ?, ?, ?, ?, ? };
  306. if (RV.isNonconcreteOK() || RV.getValue()->isComplete())
  307. continue;
  308. Success &=
  309. addCodeToMergeInOperand(R, BI, std::string(RV.getName()), NumberedOp,
  310. NamedOpIndices, Case, Target);
  311. }
  312. if (!Success) {
  313. // Dump the record, so we can see what's going on...
  314. std::string E;
  315. raw_string_ostream S(E);
  316. S << "Dumping record for previous error:\n";
  317. S << *R;
  318. PrintNote(E);
  319. }
  320. StringRef PostEmitter = R->getValueAsString("PostEncoderMethod");
  321. if (!PostEmitter.empty()) {
  322. Case += " Value = ";
  323. Case += PostEmitter;
  324. Case += "(MI, Value";
  325. Case += ", STI";
  326. Case += ");\n";
  327. }
  328. return Case;
  329. }
  330. static void emitInstBits(raw_ostream &OS, const APInt &Bits) {
  331. for (unsigned I = 0; I < Bits.getNumWords(); ++I)
  332. OS << ((I > 0) ? ", " : "") << "UINT64_C(" << utostr(Bits.getRawData()[I])
  333. << ")";
  334. }
  335. void CodeEmitterGen::emitInstructionBaseValues(
  336. raw_ostream &o, ArrayRef<const CodeGenInstruction *> NumberedInstructions,
  337. CodeGenTarget &Target, int HwMode) {
  338. const CodeGenHwModes &HWM = Target.getHwModes();
  339. if (HwMode == -1)
  340. o << " static const uint64_t InstBits[] = {\n";
  341. else
  342. o << " static const uint64_t InstBits_" << HWM.getMode(HwMode).Name
  343. << "[] = {\n";
  344. for (const CodeGenInstruction *CGI : NumberedInstructions) {
  345. Record *R = CGI->TheDef;
  346. if (R->getValueAsString("Namespace") == "TargetOpcode" ||
  347. R->getValueAsBit("isPseudo")) {
  348. o << " "; emitInstBits(o, APInt(BitWidth, 0)); o << ",\n";
  349. continue;
  350. }
  351. Record *EncodingDef = R;
  352. if (const RecordVal *RV = R->getValue("EncodingInfos")) {
  353. if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
  354. EncodingInfoByHwMode EBM(DI->getDef(), HWM);
  355. if (EBM.hasMode(HwMode))
  356. EncodingDef = EBM.get(HwMode);
  357. }
  358. }
  359. BitsInit *BI = EncodingDef->getValueAsBitsInit("Inst");
  360. // Start by filling in fixed values.
  361. APInt Value(BitWidth, 0);
  362. for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) {
  363. if (auto *B = dyn_cast<BitInit>(BI->getBit(i)); B && B->getValue())
  364. Value.setBit(i);
  365. }
  366. o << " ";
  367. emitInstBits(o, Value);
  368. o << "," << '\t' << "// " << R->getName() << "\n";
  369. }
  370. o << " UINT64_C(0)\n };\n";
  371. }
  372. void CodeEmitterGen::run(raw_ostream &o) {
  373. CodeGenTarget Target(Records);
  374. std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
  375. // For little-endian instruction bit encodings, reverse the bit order
  376. Target.reverseBitsForLittleEndianEncoding();
  377. ArrayRef<const CodeGenInstruction*> NumberedInstructions =
  378. Target.getInstructionsByEnumValue();
  379. if (any_of(NumberedInstructions, [](const CodeGenInstruction *CGI) {
  380. Record *R = CGI->TheDef;
  381. return R->getValue("Inst") && isa<DagInit>(R->getValueInit("Inst"));
  382. })) {
  383. emitVarLenCodeEmitter(Records, o);
  384. } else {
  385. const CodeGenHwModes &HWM = Target.getHwModes();
  386. // The set of HwModes used by instruction encodings.
  387. std::set<unsigned> HwModes;
  388. BitWidth = 0;
  389. for (const CodeGenInstruction *CGI : NumberedInstructions) {
  390. Record *R = CGI->TheDef;
  391. if (R->getValueAsString("Namespace") == "TargetOpcode" ||
  392. R->getValueAsBit("isPseudo"))
  393. continue;
  394. if (const RecordVal *RV = R->getValue("EncodingInfos")) {
  395. if (DefInit *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
  396. EncodingInfoByHwMode EBM(DI->getDef(), HWM);
  397. for (auto &KV : EBM) {
  398. BitsInit *BI = KV.second->getValueAsBitsInit("Inst");
  399. BitWidth = std::max(BitWidth, BI->getNumBits());
  400. HwModes.insert(KV.first);
  401. }
  402. continue;
  403. }
  404. }
  405. BitsInit *BI = R->getValueAsBitsInit("Inst");
  406. BitWidth = std::max(BitWidth, BI->getNumBits());
  407. }
  408. UseAPInt = BitWidth > 64;
  409. // Emit function declaration
  410. if (UseAPInt) {
  411. o << "void " << Target.getName()
  412. << "MCCodeEmitter::getBinaryCodeForInstr(const MCInst &MI,\n"
  413. << " SmallVectorImpl<MCFixup> &Fixups,\n"
  414. << " APInt &Inst,\n"
  415. << " APInt &Scratch,\n"
  416. << " const MCSubtargetInfo &STI) const {\n";
  417. } else {
  418. o << "uint64_t " << Target.getName();
  419. o << "MCCodeEmitter::getBinaryCodeForInstr(const MCInst &MI,\n"
  420. << " SmallVectorImpl<MCFixup> &Fixups,\n"
  421. << " const MCSubtargetInfo &STI) const {\n";
  422. }
  423. // Emit instruction base values
  424. if (HwModes.empty()) {
  425. emitInstructionBaseValues(o, NumberedInstructions, Target, -1);
  426. } else {
  427. for (unsigned HwMode : HwModes)
  428. emitInstructionBaseValues(o, NumberedInstructions, Target, (int)HwMode);
  429. }
  430. if (!HwModes.empty()) {
  431. o << " const uint64_t *InstBits;\n";
  432. o << " unsigned HwMode = STI.getHwMode();\n";
  433. o << " switch (HwMode) {\n";
  434. o << " default: llvm_unreachable(\"Unknown hardware mode!\"); break;\n";
  435. for (unsigned I : HwModes) {
  436. o << " case " << I << ": InstBits = InstBits_" << HWM.getMode(I).Name
  437. << "; break;\n";
  438. }
  439. o << " };\n";
  440. }
  441. // Map to accumulate all the cases.
  442. std::map<std::string, std::vector<std::string>> CaseMap;
  443. // Construct all cases statement for each opcode
  444. for (Record *R : Insts) {
  445. if (R->getValueAsString("Namespace") == "TargetOpcode" ||
  446. R->getValueAsBit("isPseudo"))
  447. continue;
  448. std::string InstName =
  449. (R->getValueAsString("Namespace") + "::" + R->getName()).str();
  450. std::string Case = getInstructionCase(R, Target);
  451. CaseMap[Case].push_back(std::move(InstName));
  452. }
  453. // Emit initial function code
  454. if (UseAPInt) {
  455. int NumWords = APInt::getNumWords(BitWidth);
  456. o << " const unsigned opcode = MI.getOpcode();\n"
  457. << " if (Scratch.getBitWidth() != " << BitWidth << ")\n"
  458. << " Scratch = Scratch.zext(" << BitWidth << ");\n"
  459. << " Inst = APInt(" << BitWidth << ", ArrayRef(InstBits + opcode * "
  460. << NumWords << ", " << NumWords << "));\n"
  461. << " APInt &Value = Inst;\n"
  462. << " APInt &op = Scratch;\n"
  463. << " switch (opcode) {\n";
  464. } else {
  465. o << " const unsigned opcode = MI.getOpcode();\n"
  466. << " uint64_t Value = InstBits[opcode];\n"
  467. << " uint64_t op = 0;\n"
  468. << " (void)op; // suppress warning\n"
  469. << " switch (opcode) {\n";
  470. }
  471. // Emit each case statement
  472. std::map<std::string, std::vector<std::string>>::iterator IE, EE;
  473. for (IE = CaseMap.begin(), EE = CaseMap.end(); IE != EE; ++IE) {
  474. const std::string &Case = IE->first;
  475. std::vector<std::string> &InstList = IE->second;
  476. for (int i = 0, N = InstList.size(); i < N; i++) {
  477. if (i)
  478. o << "\n";
  479. o << " case " << InstList[i] << ":";
  480. }
  481. o << " {\n";
  482. o << Case;
  483. o << " break;\n"
  484. << " }\n";
  485. }
  486. // Default case: unhandled opcode
  487. o << " default:\n"
  488. << " std::string msg;\n"
  489. << " raw_string_ostream Msg(msg);\n"
  490. << " Msg << \"Not supported instr: \" << MI;\n"
  491. << " report_fatal_error(Msg.str().c_str());\n"
  492. << " }\n";
  493. if (UseAPInt)
  494. o << " Inst = Value;\n";
  495. else
  496. o << " return Value;\n";
  497. o << "}\n\n";
  498. }
  499. }
  500. } // end anonymous namespace
  501. namespace llvm {
  502. void EmitCodeEmitter(RecordKeeper &RK, raw_ostream &OS) {
  503. emitSourceFileHeader("Machine Code Emitter", OS);
  504. CodeEmitterGen(RK).run(OS);
  505. }
  506. } // end namespace llvm