2004-08-01 07:59:33 +02:00
|
|
|
//===- AsmWriterEmitter.h - Generate an assembly writer ---------*- C++ -*-===//
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2004-08-01 07:59:33 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:37:13 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2004-08-01 07:59:33 +02: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 18:41:13 +02:00
|
|
|
#include "llvm/TableGen/TableGenBackend.h"
|
2006-07-18 19:18:03 +02:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <cassert>
|
2004-08-01 07:59:33 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
2006-07-18 19:18:03 +02:00
|
|
|
class AsmWriterInst;
|
|
|
|
class CodeGenInstruction;
|
|
|
|
|
2004-08-01 07:59:33 +02:00
|
|
|
class AsmWriterEmitter : public TableGenBackend {
|
|
|
|
RecordKeeper &Records;
|
2006-07-18 19:18:03 +02:00
|
|
|
std::map<const CodeGenInstruction*, AsmWriterInst*> CGIAWIMap;
|
|
|
|
std::vector<const CodeGenInstruction*> NumberedInstructions;
|
2004-08-01 07:59:33 +02:00
|
|
|
public:
|
|
|
|
AsmWriterEmitter(RecordKeeper &R) : Records(R) {}
|
2005-04-22 02:00:37 +02:00
|
|
|
|
2004-08-01 07:59:33 +02:00
|
|
|
// run - Output the asmwriter, returning true on failure.
|
2009-07-03 02:10:29 +02:00
|
|
|
void run(raw_ostream &o);
|
2006-07-18 19:18:03 +02:00
|
|
|
|
|
|
|
private:
|
2009-09-13 22:08:00 +02:00
|
|
|
void EmitPrintInstruction(raw_ostream &o);
|
|
|
|
void EmitGetRegisterName(raw_ostream &o);
|
2010-02-11 23:57:32 +01:00
|
|
|
void EmitGetInstructionName(raw_ostream &o);
|
2011-03-21 09:31:53 +01:00
|
|
|
void EmitRegIsInRegClass(raw_ostream &O);
|
2011-02-26 04:09:12 +01:00
|
|
|
void EmitPrintAliasInstruction(raw_ostream &O);
|
2009-09-13 22:08:00 +02:00
|
|
|
|
2006-07-18 19:18:03 +02: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 20:28:27 +02:00
|
|
|
std::vector<unsigned> &InstIdxs,
|
|
|
|
std::vector<unsigned> &InstOpsUsed) const;
|
2004-08-01 07:59:33 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|