Go to the documentation of this file.
70 resources_(resourceManager), parent_(parent),
71 isNextBegin_(true), slotNumber_(0), immediateIndex_(0) {
111 UValue srcWidth = 0, dstWidth = 0;
121 "Internal error: Immediate source must be literal or "
129 newImmediate = &newElement;
141 while(tempValue > 0) {
142 tempValue = tempValue >> 1;
154 if (newElement.
dstType != MoveElement::MF_IMM) {
157 "Long immediate destination must be immediate unit.");
165 dstWidth = resID.
width;
171 newMove = &newElement;
182 newMove = &newElement;
202 srcWidth = resID.
width;
208 newImmediate = &immediate;
212 immediate.
dstUnit = ResourceElement::INLINE_IMM;
217 newElement.
srcType = MoveElement::MF_IMM;
223 while(tempValue > 0) {
224 tempValue = tempValue >> 1;
239 dstWidth = resID.
width;
270 "Move destination: " +
272 " is already written "
273 "in current instruction.");
282 if (newMove != NULL) {
288 if ( busWidth < srcWidth) {
294 " is smaller than source: " +
299 if (dstWidth < srcWidth) {
302 "Source is wider than destination.");
308 "Too many bus slots used.");
318 if (newImmediate != NULL) {
352 Section::createSection(Section::ST_CODE));
354 assert(codeSection != NULL);
366 "Can't find code address space.");
373 std::vector<ImmediateElement*> recentImmediates;
376 for (
unsigned int i = 0;
398 recentImmediates.clear();
426 const std::string aSpaceName =
437 assert(addressSpace != NULL);
439 static_cast<unsigned int>(
440 addressSpace->
end()));
443 <<
"Could not get access to MOM address space."
449 *codeSection, *immElem, aSpaceElement, immValue,
461 ResourceElement::INLINE_IMM) {
463 recentImmediates.push_back(immElem);
567 std::vector<const InternalElement*> guardedMoves;
596 guardedMoves.push_back(&compare);
603 for (
unsigned int i = 0; i < guardedMoves.size(); i++) {
604 for (
unsigned int j = i + 1; j < guardedMoves.size(); j++) {
639 for (
unsigned int i = 0; i < elem.
annotationes.size();i++) {
641 std::vector<Byte> payload;
643 for (
unsigned int j = 0; j < elem.
annotationes[i].payload.size(); j++) {
645 std::deque<Byte> temp;
656 for (
int k =
sizeof(value) - 1; k >= 0; k--) {
658 temp.push_back(nextVal);
663 while (temp.size() > 1 && temp[0] == 0xff &&
664 temp.size() > initData.
width &&
665 (temp[1] & 0x80) != 0) {
672 while (temp[0] == 0 && temp.size() > initData.
width) {
677 while (temp.size() < initData.
width) {
680 temp.push_front(0xff);
687 if (initData.
width != 0 && temp.size() > initData.
width) {
688 std::string errorMessage =
689 "Annotation payload " + initData.
toString() +
690 " is too big for defined field size.";
698 for (
unsigned int j = 0; j < temp.size(); j++) {
699 payload.push_back(temp[j]);
void newSection(UValue startAddress)
InternalSection internalSection_
Internal representation of code section.
void setGuardInverted(bool flag)
virtual void addElement(SectionElement *element)
static const UValue CODE_RELOC_SIZE
Bitwidth of immediate value containing address to relocate.
CodeSectionCreator(MachineResourceManager &resourceManager, const TTAMachine::Machine &targetMachine, AssemblyParserDiagnostic *parent)
TPEF::Chunk * stringToChunk(const std::string aStr)
void addAnnotation(InstructionAnnotation *anAnnotation)
bool isBegin
Is first move of an instruction.
bool isBegin
Tells whether the slot is the first of the instruction.
TPEF::ResourceSection * resourceSection()
void setDestinationUnit(HalfWord aDestinationUnit)
UValue startAddress
Start address of the section.
void commitLastRelocations()
bool isGuarded
Is guard used.
TPEF::MoveElement::FieldType srcType
Source type.
UValue findBusWidth(UValue slotNumber)
void addSection(Section *section)
void setCause(const Exception &cause)
void setGuarded(bool flag)
MoveType type
Type of move.
bool isGuarded
Is guarded move.
ElementType type
Type of move.
std::string label
Name of the label.
UValue index
TPEF Resource operand id or register file index.
static std::ostream & logStream()
@ RQST_READ
Register of port for reading.
void setDestinationType(FieldType aType)
@ IMMEDIATE
Long immediate assignment.
void addMove(const ParserMove &move)
static std::string toString(const T &source)
void setBus(HalfWord aBus)
UValue srcUnit
TPEF Resource section unit id of register or port.
RegisterTerm regTerm
Guard port or register.
UValue dstIndex
TPEF Resource section operand id or register number.
UValue resolveExpressionValue(UValue asmLineNumber, LiteralOrExpression &litOrExpr)
UValue guardUnit
TPEF Resource section unit id of guard register or port.
#define assert(condition)
UValue width
Number of MAUs that are initialized by the init field.
bool isExpression
Does object contain expression or literal.
void addRelocation(TPEF::Section &locationSect, TPEF::SectionElement &location, TPEF::ASpaceElement &dstASpace, UValue destination, UValue bitWidth)
LiteralOrExpression immValue
If source is immediate, the value.
@ LONG_IMMEDIATE
Encoding of one long immediate slot.
bool isInverted
Is guard inverted.
TPEF::MoveElement::FieldType type
Resource type.
void setCodeFileLineNumber(int lineNum)
std::vector< Annotation > annotationes
Annotations for the element.
std::string toString() const
UValue width
Width of accessed port or other resource.
void setGuardIndex(HalfWord aGuardIndex)
@ RQST_INVGUARD
Inverted register or port guard.
std::string toString() const
TPEF::MoveElement::FieldType dstType
Destination type.
void startNewInstruction()
std::string aSpaceName(std::string &labelName)
TPEF::MoveElement::FieldType guardType
Guard type.
UValue slotNumber_
Slot number of current move.
void setDestinationIndex(HalfWord aDestinationIndex)
LiteralOrExpression litOrExpr
Initialisation value.
virtual AddressSpaceNavigator addressSpaceNavigator() const
UValue dstUnit
TPEF Resource section unit id of register or port.
UValue immediateIndex_
Immediate index.
void setName(const ReferenceManager::SafePointer *sectionName)
void addAnnotationes(TPEF::InstructionElement &instrElem, InternalElement &elem, LabelManager &lables) const
void setGuardType(FieldType gType)
std::string errorMessage() const
MachineResourceManager & resources_
TPEF Resources and strings.
RegisterTerm regTerm
If register, the register. Otherwise not used.
void setBegin(bool isBegin)
UValue value
If literal, the literal. Otherwise not used.
std::vector< Annotation > annotationes
LiteralOrExpression immTerm
If immediate value, the literal or expression. Otherwise not used.
TPEF::ASpaceElement & aSpaceElement(std::string &labelName)
bool isSigned
Sign of the value.
void finalize(TPEF::Binary &tpef, LabelManager &labels)
UValue unit
TPEF Resource unit id.
@ TRANSPORT
Data transport (move).
RegisterTerm destination
Destination field.
const TTAMachine::Machine & mach_
void setSourceUnit(HalfWord aSourceUnit)
void setASpace(const ReferenceManager::SafePointer *addrSpace)
UValue asmLineNumber
Line number where in source code this move is located.
@ RQST_GUARD
Register or port guard.
void setSourceIndex(HalfWord aSourceIndex)
bool isInverted
Is guard inverted.
void setLink(const ReferenceManager::SafePointer *aLink)
ResourceID & resourceID(UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type)
ParserSource source
Source field.
ComponentType * item(int index) const
Expression expression
If expression the expression, Otherwise not used.
UValue srcIndex
TPEF Resource section operand id or register number.
UValue slot
Bus slot number.
ParserGuard guard
Guard field.
TPEF::ASpaceElement * codeAddressSpace()
bool isNextBegin_
Next element is starting element of instruction.
void addWarning(UValue lineNumber, const std::string &message)
virtual ULongWord end() const
void clearLastRelocations()
AssemblyParserDiagnostic * parent_
Place to add warnings during compilation.
@ RQST_WRITE
Register or port for writing.
void setSourceType(FieldType aType)
std::vector< InternalElement > elements
Elements of the section.
void setGuardUnit(HalfWord aGuardUnit)
bool isDestinationAlreadyWritten(const InternalElement &elem) const
bool isRegister
Is source register or immediate reference.
UValue guardIndex
TPEF Resource section operand id or register number.
UValue asmLineNumber
Line number of source code for errors.