blob: 9f7d7761a497ffbeedd473aa9152a5262ca3e8ab [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- AsmWriterEmitter.h - Generate an assembly writer ---------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerfd6c2f02007-12-29 20:37:13 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This tablegen backend is responsible for emitting an assembly printer for the
11// code generator.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef ASMWRITER_EMITTER_H
16#define ASMWRITER_EMITTER_H
17
18#include "TableGenBackend.h"
19#include <map>
20#include <vector>
21#include <cassert>
22
23namespace llvm {
24 class AsmWriterInst;
25 class CodeGenInstruction;
26
27 class AsmWriterEmitter : public TableGenBackend {
28 RecordKeeper &Records;
29 std::map<const CodeGenInstruction*, AsmWriterInst*> CGIAWIMap;
30 std::vector<const CodeGenInstruction*> NumberedInstructions;
31 public:
32 AsmWriterEmitter(RecordKeeper &R) : Records(R) {}
33
34 // run - Output the asmwriter, returning true on failure.
Daniel Dunbard4287062009-07-03 00:10:29 +000035 void run(raw_ostream &o);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000036
37private:
Chris Lattner92221692009-09-13 20:08:00 +000038 void EmitPrintInstruction(raw_ostream &o);
39 void EmitGetRegisterName(raw_ostream &o);
Chris Lattner6afe7dc2010-02-11 22:57:32 +000040 void EmitGetInstructionName(raw_ostream &o);
Chris Lattner92221692009-09-13 20:08:00 +000041
Dan Gohmanf17a25c2007-07-18 16:29:46 +000042 AsmWriterInst *getAsmWriterInstByID(unsigned ID) const {
43 assert(ID < NumberedInstructions.size());
44 std::map<const CodeGenInstruction*, AsmWriterInst*>::const_iterator I =
45 CGIAWIMap.find(NumberedInstructions[ID]);
46 assert(I != CGIAWIMap.end() && "Didn't find inst!");
47 return I->second;
48 }
49 void FindUniqueOperandCommands(std::vector<std::string> &UOC,
50 std::vector<unsigned> &InstIdxs,
51 std::vector<unsigned> &InstOpsUsed) const;
52 };
53}
54#endif