2004-08-01 05:59:33 +00:00
|
|
|
//===- AsmWriterEmitter.h - Generate an assembly writer ---------*- C++ -*-===//
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2004-08-01 05:59:33 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:37:13 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2004-08-01 05:59:33 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This tablegen backend is responsible for emitting an assembly printer for the
|
|
|
|
// code generator.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ASMWRITER_EMITTER_H
|
|
|
|
#define ASMWRITER_EMITTER_H
|
|
|
|
|
2011-10-01 16:41:13 +00:00
|
|
|
#include "llvm/TableGen/TableGenBackend.h"
|
2006-07-18 17:18:03 +00:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <cassert>
|
2004-08-01 05:59:33 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2006-07-18 17:18:03 +00:00
|
|
|
class AsmWriterInst;
|
|
|
|
class CodeGenInstruction;
|
|
|
|
|
2004-08-01 05:59:33 +00:00
|
|
|
class AsmWriterEmitter : public TableGenBackend {
|
|
|
|
RecordKeeper &Records;
|
2006-07-18 17:18:03 +00:00
|
|
|
std::map<const CodeGenInstruction*, AsmWriterInst*> CGIAWIMap;
|
|
|
|
std::vector<const CodeGenInstruction*> NumberedInstructions;
|
2004-08-01 05:59:33 +00:00
|
|
|
public:
|
|
|
|
AsmWriterEmitter(RecordKeeper &R) : Records(R) {}
|
2005-04-22 00:00:37 +00:00
|
|
|
|
2004-08-01 05:59:33 +00:00
|
|
|
// run - Output the asmwriter, returning true on failure.
|
2009-07-03 00:10:29 +00:00
|
|
|
void run(raw_ostream &o);
|
2006-07-18 17:18:03 +00:00
|
|
|
|
|
|
|
private:
|
2009-09-13 20:08:00 +00:00
|
|
|
void EmitPrintInstruction(raw_ostream &o);
|
|
|
|
void EmitGetRegisterName(raw_ostream &o);
|
2010-02-11 22:57:32 +00:00
|
|
|
void EmitGetInstructionName(raw_ostream &o);
|
2011-03-21 08:31:53 +00:00
|
|
|
void EmitRegIsInRegClass(raw_ostream &O);
|
2011-02-26 03:09:12 +00:00
|
|
|
void EmitPrintAliasInstruction(raw_ostream &O);
|
2009-09-13 20:08:00 +00:00
|
|
|
|
2006-07-18 17:18:03 +00:00
|
|
|
AsmWriterInst *getAsmWriterInstByID(unsigned ID) const {
|
|
|
|
assert(ID < NumberedInstructions.size());
|
|
|
|
std::map<const CodeGenInstruction*, AsmWriterInst*>::const_iterator I =
|
|
|
|
CGIAWIMap.find(NumberedInstructions[ID]);
|
|
|
|
assert(I != CGIAWIMap.end() && "Didn't find inst!");
|
|
|
|
return I->second;
|
|
|
|
}
|
|
|
|
void FindUniqueOperandCommands(std::vector<std::string> &UOC,
|
2006-07-18 18:28:27 +00:00
|
|
|
std::vector<unsigned> &InstIdxs,
|
|
|
|
std::vector<unsigned> &InstOpsUsed) const;
|
2004-08-01 05:59:33 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|