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;
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;
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) {
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,
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]);
#define assert(condition)
static std::ostream & logStream()
void addWarning(UValue lineNumber, const std::string &message)
AssemblyParserDiagnostic * parent_
Place to add warnings during compilation.
UValue immediateIndex_
Immediate index.
void addAnnotationes(TPEF::InstructionElement &instrElem, InternalElement &elem, LabelManager &lables) const
void startNewInstruction()
@ IMMEDIATE
Long immediate assignment.
CodeSectionCreator(MachineResourceManager &resourceManager, const TTAMachine::Machine &targetMachine, AssemblyParserDiagnostic *parent)
UValue slotNumber_
Slot number of current move.
void newSection(UValue startAddress)
void addMove(const ParserMove &move)
bool isNextBegin_
Next element is starting element of instruction.
bool isDestinationAlreadyWritten(const InternalElement &elem) const
const TTAMachine::Machine & mach_
MachineResourceManager & resources_
TPEF Resources and strings.
static const UValue CODE_RELOC_SIZE
Bitwidth of immediate value containing address to relocate.
InternalSection internalSection_
Internal representation of code section.
void finalize(TPEF::Binary &tpef, LabelManager &labels)
void setCodeFileLineNumber(int lineNum)
static std::string toString(const T &source)
std::string errorMessage() const
void setCause(const Exception &cause)
std::string label
Name of the label.
std::string toString() const
LiteralOrExpression litOrExpr
Initialisation value.
UValue width
Number of MAUs that are initialized by the init field.
void clearLastRelocations()
UValue resolveExpressionValue(UValue asmLineNumber, LiteralOrExpression &litOrExpr)
std::string aSpaceName(std::string &labelName)
void commitLastRelocations()
TPEF::ASpaceElement & aSpaceElement(std::string &labelName)
void addRelocation(TPEF::Section &locationSect, TPEF::SectionElement &location, TPEF::ASpaceElement &dstASpace, UValue destination, UValue bitWidth)
bool isExpression
Does object contain expression or literal.
UValue value
If literal, the literal. Otherwise not used.
bool isSigned
Sign of the value.
Expression expression
If expression the expression, Otherwise not used.
ResourceID & resourceID(UValue currentLine, const RegisterTerm &term, UValue slotNumber, RequestType type)
UValue findBusWidth(UValue slotNumber)
@ RQST_INVGUARD
Inverted register or port guard.
@ RQST_READ
Register of port for reading.
@ RQST_WRITE
Register or port for writing.
@ RQST_GUARD
Register or port guard.
TPEF::Chunk * stringToChunk(const std::string aStr)
TPEF::ASpaceElement * codeAddressSpace()
TPEF::ResourceSection * resourceSection()
RegisterTerm regTerm
Guard port or register.
bool isInverted
Is guard inverted.
bool isGuarded
Is guard used.
@ TRANSPORT
Data transport (move).
@ LONG_IMMEDIATE
Encoding of one long immediate slot.
std::vector< Annotation > annotationes
MoveType type
Type of move.
ParserSource source
Source field.
bool isBegin
Tells whether the slot is the first of the instruction.
UValue asmLineNumber
Line number of source code for errors.
ParserGuard guard
Guard field.
RegisterTerm destination
Destination field.
bool isRegister
Is source register or immediate reference.
LiteralOrExpression immTerm
If immediate value, the literal or expression. Otherwise not used.
RegisterTerm regTerm
If register, the register. Otherwise not used.
std::string toString() const
void addSection(Section *section)
virtual void addElement(SectionElement *element)
void setBegin(bool isBegin)
void addAnnotation(InstructionAnnotation *anAnnotation)
void setGuardIndex(HalfWord aGuardIndex)
void setSourceType(FieldType aType)
void setGuardInverted(bool flag)
void setSourceIndex(HalfWord aSourceIndex)
void setBus(HalfWord aBus)
void setDestinationUnit(HalfWord aDestinationUnit)
void setGuarded(bool flag)
void setSourceUnit(HalfWord aSourceUnit)
void setGuardUnit(HalfWord aGuardUnit)
void setDestinationIndex(HalfWord aDestinationIndex)
void setDestinationType(FieldType aType)
void setGuardType(FieldType gType)
@ INLINE_IMM
Inline immediate unit id.
static Section * createSection(SectionType type)
void setLink(const ReferenceManager::SafePointer *aLink)
void setASpace(const ReferenceManager::SafePointer *addrSpace)
void setName(const ReferenceManager::SafePointer *sectionName)
virtual ULongWord end() const
ComponentType * item(int index) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
UValue guardUnit
TPEF Resource section unit id of guard register or port.
UValue srcUnit
TPEF Resource section unit id of register or port.
bool isInverted
Is guard inverted.
UValue srcIndex
TPEF Resource section operand id or register number.
ElementType type
Type of move.
TPEF::MoveElement::FieldType guardType
Guard type.
UValue slot
Bus slot number.
TPEF::MoveElement::FieldType srcType
Source type.
std::vector< Annotation > annotationes
Annotations for the element.
UValue asmLineNumber
Line number where in source code this move is located.
TPEF::MoveElement::FieldType dstType
Destination type.
LiteralOrExpression immValue
If source is immediate, the value.
UValue dstIndex
TPEF Resource section operand id or register number.
UValue dstUnit
TPEF Resource section unit id of register or port.
UValue guardIndex
TPEF Resource section operand id or register number.
bool isBegin
Is first move of an instruction.
bool isGuarded
Is guarded move.
std::vector< InternalElement > elements
Elements of the section.
UValue startAddress
Start address of the section.
UValue width
Width of accessed port or other resource.
TPEF::MoveElement::FieldType type
Resource type.
UValue index
TPEF Resource operand id or register file index.
UValue unit
TPEF Resource unit id.