mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-21 18:29:45 +00:00
instructions, and only instructions that take no operands at that! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15386 91177308-0d34-0410-b5e6-96231b3b80d8
49 lines
1.8 KiB
C++
49 lines
1.8 KiB
C++
//===- AsmWriterEmitter.cpp - Generate an assembly writer -----------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This tablegen backend is emits an assembly printer for the current target.
|
|
// Note that this is currently fairly skeletal, but will grow over time.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "AsmWriterEmitter.h"
|
|
#include "CodeGenTarget.h"
|
|
#include <ostream>
|
|
using namespace llvm;
|
|
|
|
void AsmWriterEmitter::run(std::ostream &O) {
|
|
EmitSourceFileHeader("Assembly Writer Source Fragment", O);
|
|
|
|
CodeGenTarget Target;
|
|
O <<
|
|
"/// printInstruction - This method is automatically generated by tablegen\n"
|
|
"/// from the instruction set description. This method returns true if the\n"
|
|
"/// machine instruction was sufficiently described to print it, otherwise\n"
|
|
"/// it returns false.\n"
|
|
"bool " << Target.getName()
|
|
<< "AsmPrinter::printInstruction(const MachineInstr *MI) {\n";
|
|
O << " switch (MI->getOpcode()) {\n"
|
|
" default: return false;\n";
|
|
|
|
std::string Namespace = Target.inst_begin()->second.Namespace;
|
|
|
|
for (CodeGenTarget::inst_iterator I = Target.inst_begin(),
|
|
E = Target.inst_end(); I != E; ++I)
|
|
if (!I->second.AsmString.empty()) {
|
|
const std::string &AsmString = I->second.AsmString;
|
|
O << " case " << Namespace << "::" << I->first << ": O << \""
|
|
<< AsmString << "\" << '\\n'; break;\n";
|
|
}
|
|
|
|
O << " }\n"
|
|
" return true;\n"
|
|
"}\n";
|
|
EmitSourceFileTail(O);
|
|
}
|