OpenASIP
2.0
|
#include <InlineAsmParser.hh>
Public Member Functions | |
InlineAsmParser ()=delete | |
InlineAsmParser (const InlineAsmParser &)=delete | |
InlineAsmParser & | operator= (const InlineAsmParser &)=delete |
InlineAsmParser (const llvm::TCETargetMachine &tm, const llvm::Mangler &mangler) | |
bool | parse (const llvm::MachineInstr &inlineAsmMI, const std::map< std::string, unsigned > &symbolTable, TTAProgram::BasicBlock &bb, TTAProgram::InstructionReferenceManager &irm) |
std::string | substituteAsmString (const llvm::MachineInstr &mi, const std::map< std::string, unsigned > &symbolTable, const llvm::Mangler &mangler) |
void | addLiveRangeData (const llvm::MachineInstr &mi, TTAProgram::BasicBlock &bb) |
bool | sanityChecks (const llvm::MachineInstr &mi, TTAProgram::BasicBlock &bb) const |
std::string | registerName (const llvm::MachineOperand &mo) const |
const AssemblyParserDiagnostic & | diagnostics () const |
Static Public Member Functions | |
static void | addDebugInfoToInlineAsmBB (const llvm::MachineInstr &mi, TTAProgram::BasicBlock &bb) |
static bool | isInlineAsm (const llvm::MachineInstr &mi) |
Private Member Functions | |
void | reportError (size_t lineNum, const std::string &errorMsg) |
void | reportError (const std::string &errorMsg) |
Static Private Member Functions | |
static void | copyInstructions (TTAProgram::Program &prog, TTAProgram::BasicBlock &targetBB, TTAProgram::InstructionReferenceManager &irm) |
Private Attributes | |
const llvm::TCETargetMachine & | tm_ |
The target machine parsing context. More... | |
const llvm::Mangler & | mangler_ |
The symbol name mangler for MIs' symbolic references. More... | |
AssemblyParserDiagnostic | parserDiagnostic_ |
The diagnostic object to report parse and compile warnings and errors to. More... | |
unsigned | asmId_ = 0 |
The unique id for "%=" template strings. Each parse() call increases the count. More... | |
The class for parsing TCE assembly listing written as inline assembly in C code.
The inline assembly is parsed as parallel code that does not need or should be scheduled.
Definition at line 64 of file InlineAsmParser.hh.
|
delete |
|
delete |
InlineAsmParser::InlineAsmParser | ( | const llvm::TCETargetMachine & | tm, |
const llvm::Mangler & | mangler | ||
) |
Definition at line 68 of file InlineAsmParser.cc.
|
static |
Adds gebug info to moves of the parsed inline asm.
Definition at line 159 of file InlineAsmParser.cc.
References TTAProgram::AnnotatedInstructionElement::addAnnotation(), TTAProgram::ProgramAnnotation::ANN_DEBUG_SOURCE_CODE_LINE, TTAProgram::ProgramAnnotation::ANN_DEBUG_SOURCE_CODE_PATH, getSourceLocationInfo(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TPEF::InstructionAnnotation::MAX_ANNOTATION_BYTES, TTAProgram::Instruction::move(), and TTAProgram::Instruction::moveCount().
Referenced by parse().
void InlineAsmParser::addLiveRangeData | ( | const llvm::MachineInstr & | mi, |
TTAProgram::BasicBlock & | bb | ||
) |
Fills live range data structure.
This method only fills inlineAsmX_ fields in the structure. Data dependency graph builder handles the fields later on and build the proper live range data.
Definition at line 205 of file InlineAsmParser.cc.
References assert, getInlineAsmOperands(), TTAProgram::BasicBlock::liveRangeData_, and registerName().
Referenced by parse().
|
staticprivate |
Definition at line 502 of file InlineAsmParser.cc.
References TTAProgram::CodeSnippet::add(), assert, TTAProgram::InstructionReferenceManager::createReference(), getInstructionReferenceTerminals(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Program::procedureAtIndex(), and TTAProgram::Program::procedureCount().
Referenced by parse().
|
inline |
Definition at line 99 of file InlineAsmParser.hh.
References parserDiagnostic_.
Referenced by llvm::LLVMTCEBuilder::emitInlineAsm().
|
static |
Returns true if the instruction represents an inline asm block recognized by this parser.
Definition at line 450 of file InlineAsmParser.cc.
Referenced by llvm::LLVMTCEBuilder::isInlineAsm(), and substituteAsmString().
|
delete |
bool InlineAsmParser::parse | ( | const llvm::MachineInstr & | inlineAsmMI, |
const std::map< std::string, unsigned > & | symbolTable, | ||
TTAProgram::BasicBlock & | bb, | ||
TTAProgram::InstructionReferenceManager & | irm | ||
) |
Parses the given inline assembly instruction to POM basic block.
After call parser diagnostic object is populated with encountered warning and error reports if any. The object is received via diagnostics() function. The object is cleared next time this method is called.
inlineAsmMI | The Instruction holding an inline asm block. |
bb | The basic block to add parsed code into. |
irm | The manager in where instruction references are copied to. |
Definition at line 87 of file InlineAsmParser.cc.
References addDebugInfoToInlineAsmBB(), addLiveRangeData(), assert, TTAProgram::TPEFProgramFactory::build(), AssemblerParser::compile(), copyInstructions(), AssemblerParser::errorLine(), Exception::errorMessage(), AssemblerParser::finalize(), TTAMachine::Machine::isLittleEndian(), mangler_, parserDiagnostic_, reportError(), AssemblyParserDiagnostic::reset(), sanityChecks(), substituteAsmString(), tm_, TTAProgram::CodeSnippet::toString(), and llvm::TCETargetMachine::ttaMachine().
Referenced by llvm::LLVMTCEBuilder::emitInlineAsm().
std::string InlineAsmParser::registerName | ( | const llvm::MachineOperand & | mo | ) | const |
Returns register name of the machine operand (of reg type).
Definition at line 268 of file InlineAsmParser.cc.
References assert, llvm::TCETargetMachine::registerName(), and tm_.
Referenced by addLiveRangeData().
|
private |
Definition at line 468 of file InlineAsmParser.cc.
References AssemblyParserDiagnostic::addError(), and parserDiagnostic_.
|
private |
Definition at line 463 of file InlineAsmParser.cc.
References AssemblyParserDiagnostic::addError(), and parserDiagnostic_.
Referenced by parse().
bool InlineAsmParser::sanityChecks | ( | const llvm::MachineInstr & | mi, |
TTAProgram::BasicBlock & | bb | ||
) | const |
Performs sanity checks of parsed inline asm snippet.
The method reports issues to the diagnostic object.
Definition at line 251 of file InlineAsmParser.cc.
Referenced by parse().
std::string InlineAsmParser::substituteAsmString | ( | const llvm::MachineInstr & | mi, |
const std::map< std::string, unsigned > & | symbolTable, | ||
const llvm::Mangler & | mangler | ||
) |
Returns substituted assembly string.
mi | The instruction holding the inline asm. |
symbolTable | Table to traslate mangled names to addresses. |
mangler | The name mangler. |
Definition at line 281 of file InlineAsmParser.cc.
References asmId_, assert, getInlineAsmOperands(), getSourceLocationInfo(), isInlineAsm(), llvm::TCETargetMachine::registerName(), Application::spamVerbose(), THROW_EXCEPTION, tm_, and Conversion::toInt().
Referenced by parse().
|
private |
The unique id for "%=" template strings. Each parse() call increases the count.
Definition at line 125 of file InlineAsmParser.hh.
Referenced by substituteAsmString().
|
private |
The symbol name mangler for MIs' symbolic references.
Definition at line 119 of file InlineAsmParser.hh.
Referenced by parse().
|
private |
The diagnostic object to report parse and compile warnings and errors to.
Definition at line 122 of file InlineAsmParser.hh.
Referenced by diagnostics(), parse(), and reportError().
|
private |
The target machine parsing context.
Definition at line 117 of file InlineAsmParser.hh.
Referenced by parse(), registerName(), and substituteAsmString().