#include <instruction.h>
Public Types | |
| enum | InstructionPosition { InterruptHandler = 0, LookupTable = 1, Middle = 2, Subroutine = 3, PositionCount = 4 } |
| typedef CodeIterator | iterator |
| typedef CodeConstIterator | const_iterator |
Public Member Functions | |
| Code () | |
| CodeIterator | begin () |
| CodeIterator | end () |
| CodeConstIterator | begin () const |
| CodeConstIterator | end () const |
| void | queueLabel (const QString &label, InstructionPosition position=Middle) |
| QStringList | queuedLabels (InstructionPosition position) const |
| void | append (Instruction *instruction, InstructionPosition position=Middle) |
| Instruction * | instruction (const QString &label) const |
| iterator | find (Instruction *instruction) |
| void | removeInstruction (Instruction *instruction) |
| QString | generateCode (PIC14 *pic) const |
| void | merge (Code *code, InstructionPosition middleInsertionPosition=Middle) |
| InstructionList * | instructionList (InstructionPosition position) |
| const InstructionList * | instructionList (InstructionPosition position) const |
| void | generateLinksAndStates () |
| void | setAllUnused () |
| void | postCompileConstruct () |
Protected Member Functions | |
| QStringList | findVariables () const |
Protected Attributes | |
| InstructionList | m_instructionLists [PositionCount] |
| |
| QStringList | m_queuedLabels [PositionCount] |
| |
Definition at line 468 of file instruction.h.
| Middle | Used for main code. |
| Subroutine | Used for subroutines. |
| PositionCount | This must remain the last item and be the number of valid positions. |
Definition at line 476 of file instruction.h.
| void Code::queueLabel | ( | const QString & | label, | |
| InstructionPosition | position = Middle | |||
| ) |
Queues a label to be given to the next instruction to be added in the given position
Definition at line 823 of file instruction.cpp.
References m_queuedLabels.
Referenced by PIC14::addCommonFunctions(), PIC14::divide(), PIC14::equal(), PIC14::greaterOrEqual(), PIC14::greaterThan(), PIC14::lessOrEqual(), PIC14::lessThan(), PIC14::multiply(), PIC14::notEqual(), PIC14::postCompileConstruct(), PIC14::Sfor(), PIC14::Sinterrupt(), PIC14::Skeypad(), PIC14::Slabel(), PIC14::Spin(), PIC14::Srepeat(), PIC14::SsevenSegment(), PIC14::Ssubroutine(), and PIC14::Swhile().
| QStringList Code::queuedLabels | ( | InstructionPosition | position | ) | const [inline] |
Returns the list of queued labels for the given position. This is used in merging code, as we also need to merge any queued labels.
Definition at line 500 of file instruction.h.
References m_queuedLabels.
Referenced by merge().
| void Code::append | ( | Instruction * | instruction, | |
| InstructionPosition | position = Middle | |||
| ) |
Adds the Instruction at the given position.
Definition at line 878 of file instruction.cpp.
References Instruction::addLabels(), instruction(), m_instructionLists, m_queuedLabels, removeInstruction(), Instruction::setCode(), and Instruction::type().
Referenced by PIC14::add(), PIC14::addCommonFunctions(), PIC14::assignNum(), PIC14::assignVar(), PIC14::bitwise(), PIC14::div(), PIC14::divide(), PIC14::equal(), PIC14::greaterOrEqual(), PIC14::greaterThan(), PIC14::ifInitCode(), PIC14::lessOrEqual(), PIC14::lessThan(), merge(), PIC14::mul(), PIC14::multiply(), PIC14::notEqual(), Parser::parse(), PIC14::postCompileConstruct(), PIC14::Sasm(), PIC14::saveResultToVar(), PIC14::saveToReg(), PIC14::Scall(), PIC14::SdecVar(), PIC14::Sdelay(), PIC14::Send(), PIC14::Sfor(), PIC14::Sgoto(), PIC14::SincVar(), PIC14::Sinterrupt(), PIC14::Skeypad(), PIC14::Spin(), PIC14::Srepeat(), PIC14::SrotlVar(), PIC14::SrotrVar(), PIC14::Ssetlh(), PIC14::SsevenSegment(), PIC14::Ssubroutine(), PIC14::Stristate(), PIC14::subtract(), and PIC14::Swhile().
| Instruction * Code::instruction | ( | const QString & | label | ) | const |
Definition at line 901 of file instruction.cpp.
References begin(), end(), m_instructionLists, and PositionCount.
Referenced by append(), find(), Instruction::makeLabelOutputLink(), Instr_call::makeReturnLinks(), PIC14::multiply(), removeInstruction(), PIC14::Skeypad(), and PIC14::SsevenSegment().
| Code::iterator Code::find | ( | Instruction * | instruction | ) |
Look for an Assembly instruction (other types are ignored).
Definition at line 916 of file instruction.cpp.
References begin(), end(), and instruction().
Referenced by Instr_call::linkReturns().
| void Code::removeInstruction | ( | Instruction * | instruction | ) |
Removes the Instruction (regardless of position).
Definition at line 830 of file instruction.cpp.
References begin(), end(), instruction(), CodeIterator::it, Instruction::labels(), and CodeIterator::list.
Referenced by append(), and CodeIterator::removeAndIncrement().
| QString Code::generateCode | ( | PIC14 * | pic | ) | const |
Merges all the blocks output together with other magic such as adding variables, gpasm directives, etc.
Definition at line 963 of file instruction.cpp.
References begin(), CodeIterator::code, end(), findVariables(), PIC14::gprStart(), m_instructionLists, PIC14::minimalTypeString(), and PositionCount.
Referenced by Microbe::compile().
| void Code::merge | ( | Code * | code, | |
| InstructionPosition | middleInsertionPosition = Middle | |||
| ) |
Appends the InstructionLists to the end of the ones in this instance.
| middleInsertionPosition | is the position where the middle code blocks of the given code will be merged at. |
Definition at line 798 of file instruction.cpp.
References append(), end(), instructionList(), m_queuedLabels, Middle, PositionCount, and queuedLabels().
Referenced by PIC14::mergeCode(), PIC14::Sfor(), PIC14::Sinterrupt(), PIC14::Srepeat(), and PIC14::Ssubroutine().
| InstructionList* Code::instructionList | ( | InstructionPosition | position | ) | [inline] |
Definition at line 537 of file instruction.h.
References m_instructionLists.
Referenced by merge(), CodeConstIterator::operator++(), and CodeIterator::operator++().
| const InstructionList* Code::instructionList | ( | InstructionPosition | position | ) | const [inline] |
Definition at line 541 of file instruction.h.
References m_instructionLists.
| void Code::generateLinksAndStates | ( | ) |
Calls generateOutputLinks for each Instruction
Definition at line 1031 of file instruction.cpp.
References begin(), and end().
Referenced by Optimizer::propagateLinksAndStates().
| void Code::setAllUnused | ( | ) |
Calls setUsed(false) for all instructions.
Definition at line 1056 of file instruction.cpp.
References begin(), and end().
Referenced by Optimizer::generateRegisterDepends(), Instr_call::makeReturnLinks(), and Optimizer::optimizeInstructions().
| void Code::postCompileConstruct | ( | ) |
Does any work that is needed to the code before it can be passed to the optimizer (such as flushing out queued labels). This is called after all the instructions have been added to the code.
Definition at line 929 of file instruction.cpp.
References begin(), end(), m_instructionLists, m_queuedLabels, and PositionCount.
Referenced by Microbe::compile().
| QStringList Code::findVariables | ( | ) | const [protected] |
Used when generating the code. Finds the list of general purpose registers that are referenced and returns their aliases.
Definition at line 1012 of file instruction.cpp.
References begin(), and end().
Referenced by generateCode().
1.5.1