OpenASIP 2.2
Loading...
Searching...
No Matches
BEMTester.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file BEMTester.cc
26 *
27 * Implementation of BEMTester class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <algorithm>
34
35#include "BEMTester.hh"
36#include "BEMTools.hh"
37#include "SlotField.hh"
38#include "MoveSlot.hh"
39#include "SocketEncoding.hh"
40#include "SourceField.hh"
41#include "GuardField.hh"
42#include "GPRGuardEncoding.hh"
43#include "FUGuardEncoding.hh"
45#include "DestinationField.hh"
46#include "BridgeEncoding.hh"
47#include "ImmediateEncoding.hh"
48#include "NOPEncoding.hh"
49#include "SocketCodeTable.hh"
50#include "FUPortCode.hh"
51#include "RFPortCode.hh"
52#include "IUPortCode.hh"
53#include "MathTools.hh"
54
55/**
56 * Tests whether the given encoding can be added to the given slot
57 * field.
58 *
59 * The encoding can not be added to the slot field if some other
60 * socket encoding, bridge encoding, immediate encoding or NOP
61 * encoding has exactly the same bits in same positions. For example,
62 * if socket (and bridge) ID's are in the left end of the slot field,
63 * the encodings '1001' and '10' would conflict, since in both cases
64 * the two leftmost bits in the field are '10'.
65 *
66 * @param field The slot field.
67 * @param encoding The encoding.
68 * @param extraBits The number of extra bits in the encoding.
69 * @return True if the encoding can be added to the slot field, otherwise
70 * false.
71 */
72bool
74 SlotField& field,
75 unsigned int encoding,
76 unsigned int extraBits) {
77
78 unsigned int encodingWidth = MathTools::bitLength(encoding) +
79 extraBits;
80
81 int socketEncodings = field.socketEncodingCount();
82 for (int i = 0; i < socketEncodings; i++) {
83 SocketEncoding& existingEnc = field.socketEncoding(i);
84 int alignment = calculateAlignment(
85 encodingWidth, existingEnc.socketIDWidth(), field);
86 int commonBits = commonBitCount(
87 encoding, extraBits, existingEnc.encoding(),
88 existingEnc.extraBits(), alignment);
89 if (commonBits == static_cast<int>(MathTools::bitLength(encoding))
90 + static_cast<int>(extraBits) ||
91 commonBits == existingEnc.socketIDWidth()) {
92 return false;
93 }
94 }
95
96 SourceField* sField = dynamic_cast<SourceField*>(&field);
97 if (sField != NULL) {
98 int bridgeEncodings = sField->bridgeEncodingCount();
99 for (int i = 0; i < bridgeEncodings; i++) {
100 BridgeEncoding& existingEnc = sField->bridgeEncoding(i);
101 int alignment = calculateAlignment(
102 encodingWidth, existingEnc.width(), field);
103 int commonBits = commonBitCount(
104 encoding, extraBits, existingEnc.encoding(),
105 existingEnc.extraBits(), alignment);
106 if (commonBits == static_cast<int>(
107 MathTools::bitLength(encoding)) +
108 static_cast<int>(extraBits) ||
109 commonBits == existingEnc.width()) {
110 return false;
111 }
112 }
113
114 if (sField->hasImmediateEncoding()) {
115 ImmediateEncoding& immEnc = sField->immediateEncoding();
116 int alignment = calculateAlignment(
117 encodingWidth, immEnc.width(), field);
118 int commonBits = commonBitCount(
119 encoding, extraBits, immEnc.encoding(), immEnc.extraBits(),
120 alignment);
121 if (commonBits ==
122 static_cast<int>(MathTools::bitLength(encoding)) +
123 static_cast<int>(extraBits) ||
124 commonBits == immEnc.width()) {
125 return false;
126 }
127 }
128
129 if (sField->hasNoOperationEncoding()) {
130 NOPEncoding& nopEnc = sField->noOperationEncoding();
131 int alignment = calculateAlignment(
132 encodingWidth, nopEnc.width(), field);
133 int commonBits = commonBitCount(
134 encoding, extraBits, nopEnc.encoding(), nopEnc.extraBits(),
135 alignment);
136 if (commonBits == static_cast<int>(
137 MathTools::bitLength(encoding)) +
138 static_cast<int>(extraBits) ||
139 commonBits == nopEnc.width()) {
140 return false;
141 }
142 }
143
144 }
145 return true;
146}
147
148/**
149 * Tests whether the given priority encoding can be added to the given move
150 * slot field.
151 *
152 * The encoding can be added to the slot if it distinguishable from the other
153 * encodings in the slot. The encoding is distinguishable if there is no
154 * guard, source and destination field encoding combination that could be
155 * misunderstood as the given encoding.
156 *
157 * The tested encoding is treated as it has higher priority in decoding. That
158 * is, is the given encoding is present in the move slot, then any other
159 * encoding bits (non-overlapping with the given encoding) in the slot does
160 * not have effect.
161 *
162 * The tested encoding can cross boundaries of guard, source and destination
163 * fields, overlapping multiple fields. A par of the encoding (i.e.
164 * overlapping some slot field) may be indistinguishable as long as some other
165 * parts are distinguishable.
166 *
167 * @param slot The slot where the encoding could be added.
168 * @param encoding The encoding value. Avoid using zero value since its bit
169 * width is zero too. Instead, use one extrabit denote zero
170 * value.
171 * @param extraBits The extra bits (zeroes) of the the encoding at the left
172 * side.
173 * @param offset The position of the encoding from LSB position of the slot.
174 * Zero means that the given encoding is right aligned in the
175 * slot.
176 * @return True if the encoding is distinguishable from the other
177 * encodings and, therefore, can be added to the slot.
178 */
179bool
181 MoveSlot& slot, unsigned int encoding, unsigned int extraBits,
182 int offset) {
183 bool canAdd = false;
184 int encWidth = BEMTools::encodingWidth(encoding, extraBits);
185 unsigned truncatedEnc;
186 unsigned truncatedWidth;
187 int offsetInField;
188
189 if (encWidth + offset > slot.width()) {
190 // The move NOP encoding can be always added if (part of the) it is
191 // located out side of the move slot fields.
192 // note: this assumes that the move slot does not have other kinds of
193 // move encodings.
194 return true;
195 }
196
197 if (fieldsOverlap(slot.guardField(), encWidth, offset)) {
198 std::tie(truncatedEnc, truncatedWidth, offsetInField) = splitEncoding(
199 encoding, encWidth, slot.guardField().width(),
200 offset - slot.guardField().bitPosition());
201
202 canAdd = canAdd || !conflictsWithGuardEncoding(
203 slot.guardField(), truncatedEnc,
204 truncatedWidth, offsetInField);
205 }
206
207 if (fieldsOverlap(slot.sourceField(), encWidth, offset)) {
208 const SourceField& field = slot.sourceField();
209 std::tie(truncatedEnc, truncatedWidth, offsetInField) = splitEncoding(
210 encoding, encWidth, field.width(), offset - field.bitPosition());
211
212 canAdd =
214 field, truncatedEnc, truncatedWidth, offsetInField);
215 }
216
217 if (fieldsOverlap(slot.destinationField(), encWidth, offset)) {
218 const DestinationField& field = slot.destinationField();
219 std::tie(truncatedEnc, truncatedWidth, offsetInField) = splitEncoding(
220 encoding, encWidth, field.width(), offset - field.bitPosition());
221
222 canAdd =
224 field, truncatedEnc, truncatedWidth, offsetInField);
225 }
226
227 return canAdd;
228}
229
230/**
231 * Tells whether the given port encoding can be added to the given socket
232 * code table.
233 *
234 * The given encoding is be ambiguous with some other FU port encoding or RF
235 * port encoding in the socket code table if all the bits of the encoding are
236 * the same with the bits of another encoding in the same position of the
237 * field. For example, encodings 1011 and 11 are ambiguous if the LSBs of
238 * the encodings are in the same position.
239 *
240 * @param table The socket code table.
241 * @param encoding The encoding.
242 * @param extraBits The number of extra bits in the encoding.
243 * @return True if the encoding can be added to the socket code table,
244 * otherwise false.
245 */
246bool
248 SocketCodeTable& table,
249 unsigned int encoding,
250 unsigned int extraBits) {
251
252 int encodingWidth = MathTools::bitLength(encoding) + extraBits;
253
254 int fuPortEncodings = table.fuPortCodeCount();
255 for (int i = 0; i < fuPortEncodings; i++) {
256 FUPortCode& code = table.fuPortCode(i);
257 int commonBits = commonBitCount(
258 encoding, extraBits, code.encoding(), code.extraBits(),
259 code.encodingWidth() - encodingWidth);
260 if (commonBits == encodingWidth ||
261 commonBits == code.encodingWidth()) {
262 return false;
263 }
264 }
265
266 int rfPortEncodings = table.rfPortCodeCount();
267 for (int i = 0; i < rfPortEncodings; i++) {
268 RFPortCode& code = table.rfPortCode(i);
269 int commonBits = commonBitCount(
270 encoding, extraBits, code.encoding(), code.extraBits(),
271 code.encodingWidth() - encodingWidth);
272 if (commonBits == encodingWidth ||
273 commonBits == code.encodingWidth()) {
274 return false;
275 }
276 }
277
278 int iuPortEncodings = table.iuPortCodeCount();
279 for (int i = 0; i < iuPortEncodings; i++) {
280 IUPortCode& code = table.iuPortCode(i);
281 int commonBits = commonBitCount(
282 encoding, extraBits, code.encoding(), code.extraBits(),
283 code.encodingWidth() - encodingWidth);
284 if (commonBits == encodingWidth ||
285 commonBits == code.encodingWidth()) {
286 return false;
287 }
288 }
289
290 return true;
291}
292
293
294/**
295 * Tells the number of common bits in the same positions in the given
296 * encodings. The LSB bit of the encodings may not be in the same position.
297 * That is defined by the alignment parameter.
298 *
299 * @param enc1 The first encoding.
300 * @param extraBits1 The number of extra zero bits in the first encoding.
301 * @param enc2 The second encoding.
302 * @param extraBits2 The number of extra zero bits in the second encoding.
303 * @param alignment The number of bits the second encoding has in the right
304 * side of the first encoding (negative if the LSB bit of
305 * the second encoding is on the left side of the LSB bit of
306 * the first encoding).
307 */
308int
310 unsigned int enc1,
311 unsigned int extraBits1,
312 unsigned int enc2,
313 unsigned int extraBits2,
314 int alignment) {
315
316 int commonBits(0);
317
318 int enc1Offset = 0;
319 int enc2Offset = 0;
320
321 if (alignment > 0) {
322 enc2Offset = alignment;
323 } else if (alignment < 0) {
324 enc1Offset = alignment * (-1);
325 }
326
327 int maxEnc1Offset = MathTools::bitLength(enc1) + extraBits1 - 1;
328 int maxEnc2Offset = MathTools::bitLength(enc2) + extraBits2 - 1;
329
330 while (enc1Offset <= maxEnc1Offset && enc2Offset <= maxEnc2Offset) {
331 if (MathTools::bit(enc1, enc1Offset) ==
332 MathTools::bit(enc2, enc2Offset)) {
333 commonBits++;
334 }
335 enc1Offset++;
336 enc2Offset++;
337 }
338
339 return commonBits;
340}
341
342/**
343 * Calculates the alignment of encodings that has the given widths when they
344 * are added to the given slot field.
345 *
346 * @param enc1Width Width of the first encoding.
347 * @param enc2Width Width of the second encoding.
348 * @param field The slot field.
349 * @return The alignment.
350 */
351int
353 unsigned int enc1Width,
354 unsigned int enc2Width,
355 const SlotField& field) {
356
358 return 0;
359 } else {
360 return enc2Width - enc1Width;
361 }
362}
363
364/**
365 * Checks if a field relatively at position to an instruction field do
366 * overlap.
367 *
368 * @verbatim
369 * |<- instruction field ->|
370 * |<-- width -->|<---- pos --|
371 * ------------------------------0
372 * => true
373 * @endverbatim
374 *
375 * @param with
376 * @param toFieldWidth
377 * @param toFieldPos The relative position of the field to the instruction
378 * field.
379 * @return True if the fields do overlap. Otherwise false.
380 */
381bool
383 const InstructionField& with, unsigned int toFieldWidth, int toFieldPos) {
384 return fieldsOverlap(
385 with.width(), with.bitPosition(), toFieldWidth, toFieldPos);
386}
387
388/**
389 * Checks if the given fields overlaps
390 *
391 * @verbatim
392 * |- pos1 -->|
393 * |<------ width1 ------>|
394 * |<- width2 ->| |
395 * |<- pos2 -|
396 * <- + 0
397 * ->| |<- overlaps => true
398 * @endverbatim
399 *
400 * @param width1 The width of the 1st field.
401 * @param pos1 The position of the 1st field.
402 * @param width2 The width of the 2nd field.
403 * @param pos2 The position of the 2nd field.
404 * @return True if there is overlap. Otherwise return false.
405 */
406bool
408 unsigned width1, int pos1, unsigned width2, int pos2) {
409 // positive = overlapping width, negative = separation width
410 return (std::min(
411 pos1 + static_cast<int>(width1),
412 pos2 + static_cast<int>(width2)) -
413 std::max(pos1, pos2)) > 0;
414}
415
416/**
417 * Checks that the given encoding and others in the field can be distinguished
418 * from each other.
419 *
420 * @param field The guard field.
421 * @param encoding The encoding.
422 * @param width The width of the encoding where the encoding value is right
423 * aligned.
424 * @param offset The relative position of the encoding to the field's LSB.
425 * Positive shifts the encoding towards MSB and vice versa.
426 * @return True if the encoding can not be distinguished from another
427 * encoding.
428 */
429bool
431 const GuardField& field, unsigned int encoding, unsigned int /*width*/,
432 int offset) {
433 for (int i = 0; i < field.gprGuardEncodingCount(); i++) {
434 const GPRGuardEncoding& grdEnc = field.gprGuardEncoding(i);
435
437 grdEnc.encoding(), 0, encoding, offset, field.width())) {
438 return true;
439 }
440 }
441
442 for (int i = 0; i < field.fuGuardEncodingCount(); i++) {
443 const FUGuardEncoding& grdEnc = field.fuGuardEncoding(i);
444
446 grdEnc.encoding(), 0, encoding, offset, field.width())) {
447 return true;
448 }
449 }
450
451 if (field.hasUnconditionalGuardEncoding(false)) {
452 const UnconditionalGuardEncoding& grdEnc =
453 field.unconditionalGuardEncoding(false);
454
456 grdEnc.encoding(), 0, encoding, offset, field.width())) {
457 return true;
458 }
459 }
460
461 if (field.hasUnconditionalGuardEncoding(true)) {
462 const UnconditionalGuardEncoding& grdEnc =
463 field.unconditionalGuardEncoding(true);
464
466 grdEnc.encoding(), 0, encoding, offset, field.width())) {
467 return true;
468 }
469 }
470
471 return false;
472}
473
474/**
475 * Checks that the given encoding and others in the field can be distinguished
476 * from each other.
477 *
478 * @param field The source field.
479 * @param encoding The encoding.
480 * @param width The width of the encoding where the encoding value is right
481 * aligned.
482 * @param offset The relative position of the encoding to the field's LSB.
483 * Positive shifts the encoding towards MSB and vice versa.
484 * @return True if the encoding can not be distinguished from another
485 * encoding.
486 */
487bool
489 const SourceField& field, unsigned int encoding, unsigned int width,
490 int offset) {
491 unsigned truncatedEncoding;
492 unsigned truncatedWidth;
493 unsigned truncatedOffset;
494
495 for (int i = 0; i < field.socketEncodingCount(); i++) {
496 const SocketEncoding& socketEnc = field.socketEncoding(i);
497
498 bool socketIDOverlap = fieldsOverlap(
499 socketEnc.socketIDWidth(), socketEnc.socketIDPosition(), width,
500 offset);
501 std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
502 splitEncodingTo(socketEnc, encoding, width, offset);
503 bool socketIDMatch = MathTools::bitFieldsEquals(
504 socketEnc.encoding(), truncatedOffset, truncatedEncoding, 0,
505 truncatedWidth);
506
507 const SocketCodeTable& scTable = socketEnc.socketCodes();
508 // Get the part that overlaps with port codes.
509 std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
511 encoding, width, scTable.width(),
512 offset - socketEnc.socketCodePosition());
513 bool socketCodeOverlap = truncatedWidth > 0;
514 bool socketCodeMatch = conflictsWithSocketTableEncodings(
515 scTable, truncatedEncoding, truncatedWidth, truncatedOffset);
516
517 if (socketIDOverlap) {
518 if (socketCodeMatch && socketIDMatch && socketCodeMatch) {
519 return true;
520 } else if (!socketCodeOverlap && socketIDMatch) {
521 return true;
522 }
523 } else if (socketCodeOverlap && socketCodeMatch) {
524 return true;
525 }
526 }
527
528 // check against simm
529 if (field.hasImmediateEncoding()) {
530 const ImmediateEncoding& simmEnc = field.immediateEncoding();
531 std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
533 encoding, width, simmEnc.encodingWidth(),
534 offset - simmEnc.encodingPosition());
535
537 simmEnc.encoding(), truncatedOffset, truncatedEncoding, 0,
538 truncatedWidth)) {
539 return true;
540 }
541 }
542
543 return false;
544}
545
546/**
547 * Checks that the given encoding and others in the field can be distinguished
548 * from each other.
549 *
550 * @param field The destination field.
551 * @param encoding The encoding.
552 * @param width The width of the encoding where the encoding value is right
553 * aligned.
554 * @param offset The relative position of the encoding to the field's LSB.
555 * Positive shifts the encoding towards MSB and vice versa.
556 * @return True if the encoding can not be distinguished from another
557 * encoding.
558 */
559bool
561 const DestinationField& field, unsigned int encoding, unsigned int width,
562 int offset) {
563 unsigned truncatedEncoding;
564 unsigned truncatedWidth;
565 unsigned truncatedOffset;
566
567 for (int i = 0; i < field.socketEncodingCount(); i++) {
568 const SocketEncoding& socketEnc = field.socketEncoding(i);
569 std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
570 splitEncodingTo(socketEnc, encoding, width, offset);
571
572 bool socketIDOverlap = fieldsOverlap(
573 socketEnc.socketIDWidth(), socketEnc.socketIDPosition(), width,
574 offset);
575 bool socketIDMatch = MathTools::bitFieldsEquals(
576 socketEnc.encoding(), truncatedOffset, truncatedEncoding, 0,
577 truncatedWidth);
578
579 const SocketCodeTable& scTable = socketEnc.socketCodes();
580 // Get the part that overlaps with port codes.
581 std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
583 encoding, width, scTable.width(),
584 offset - socketEnc.socketCodePosition());
585
586 bool socketCodeOverlap = truncatedWidth > 0;
587 bool socketCodeMatch = conflictsWithSocketTableEncodings(
588 scTable, truncatedEncoding, truncatedWidth, truncatedOffset);
589
590 if (socketIDOverlap) {
591 if (socketCodeOverlap && socketIDMatch && socketCodeMatch) {
592 return true;
593 } else if (!socketCodeOverlap && socketIDMatch) {
594 return true;
595 }
596 } else if (socketCodeOverlap && socketCodeMatch) {
597 return true;
598 }
599 }
600
601 return false;
602}
603
604/**
605 * Checks that the given encoding and others in the socket table can be
606 * distinguished from each other.
607 *
608 * @param scTable The socket code table.
609 * @param encoding The encoding.
610 * @param width The width of the encoding where the encoding value is right
611 * aligned.
612 * @param offset The relative position of the encoding to the field's LSB.
613 * Positive shifts the encoding towards MSB and vice versa.
614 * @return True if the encoding can not be distinguished from another
615 * encoding.
616 */
617bool
619 const SocketCodeTable& scTable, unsigned int encoding, unsigned int width,
620 int offset) {
621 // The conflict checking assumes that port code is encoded as:
622 // |<- width ->|
623 // | encoding |<- (offset > 0) ------------------------|
624 // | extrabits | port code encoding | unused bits | index width |
625 // |<- socket code table width ->|
626 // msb lsb: 0
627 // note: port code encoding is left aligned and index bits are right
628 // aligned, leaving unused bits between them if table width
629 // is wider than the port code width.
630
631 for (int i = 0; i < scTable.portCodeCount(); i++) {
632 const PortCode& portCode = scTable.portCode(i);
633 // Check port code encoding
634 if (portCode.encodingWidth() > 0) {
635 // note: extrabits of SocketCodeTable are not considered.
637 encoding, 0, portCode.encoding(),
638 portCode.encodingWidth() - width, width)) {
639 return true;
640 }
641 }
642
643 // Check index part
644 if (portCode.indexWidth() > 0) {
645 if (fieldsOverlap(portCode.indexWidth(), 0, width, offset)) {
646 // todo/note: check if suggested encoding lands on unused
647 // index (when isMaxIndexSet() == true. Currently the feature
648 // is not used anywhere).
649 return true;
650 }
651 }
652 }
653 return false;
654}
655
656/**
657 *
658 * Splits encoding to the target field.
659 *
660 * the splitted encoding is returned as tuple where the 1st item is encoding
661 * bits leaving out non-overlapping bits, the 2nd item is resulted width
662 * (width of overlap) and the 3rd item is position of the resulted encoding
663 * within the target field.
664 *
665 * @verbatim
666 * msb lsb
667 * |<- encoding width ->|
668 * |00001010110100100100|
669 * |<-- offset (>0) --|
670 * |<- target width ->|
671 *----------------------------------------------
672 * result encoding: |0100100|
673 * result width: |<----->|<-- offset (>0) --|
674 * @endverbatim
675 */
676std::tuple<unsigned, unsigned, int>
678 unsigned encoding, unsigned encodingWidth, unsigned targetWidth,
679 int offsetToTarget) {
680 long int resultWidth =
681 std::min(
682 static_cast<int>(targetWidth),
683 offsetToTarget + static_cast<int>(encodingWidth)) -
684 std::max(0, offsetToTarget);
685
686 if (offsetToTarget > static_cast<int>(targetWidth) || resultWidth <= 0) {
687 return std::make_tuple(0, 0, 0);
688 }
689
690 unsigned resultEncoding = encoding;
691 int resultOffset = offsetToTarget;
692
693 if (offsetToTarget < 0) {
694 assert(-offsetToTarget < 32 && "Invalid shift amount.");
695 resultEncoding = resultEncoding >> -offsetToTarget;
696 resultOffset = 0;
697 }
698 assert(resultWidth < 32 && "Invalid shift amount.");
699 unsigned mask = ~(~(0u) << resultWidth);
700 resultEncoding &= mask;
701 return std::make_tuple(resultEncoding, resultWidth, resultOffset);
702}
703
704/**
705 * Splits the given encoding that overlaps with the SocketEncoding.
706 *
707 * Returns tuple where the 1st item is encoding bits leaving out
708 * non-overlapping bits, the 2nd item is resulted width (width of the overlap)
709 * and the 3rd item is position of the resulted encoding within the
710 * SocketEncoding.
711 */
712std::tuple<unsigned, unsigned, int>
714 const SocketEncoding& socketEncoding, unsigned encoding,
715 unsigned encodingWidth, int offsetToTarget) {
716 return splitEncoding(
717 encoding, encodingWidth, socketEncoding.socketIDWidth(),
718 offsetToTarget - socketEncoding.socketIDPosition());
719}
#define assert(condition)
static bool canAddComponentEncoding(SlotField &field, unsigned int encoding, unsigned int extraBits)
Definition BEMTester.cc:73
static bool conflictsWithSourceEncodings(const SourceField &field, unsigned int encoding, unsigned int width, int offset)
Definition BEMTester.cc:488
static int commonBitCount(unsigned int enc1, unsigned int extraBits1, unsigned int enc2, unsigned int extraBits2, int alignment)
Definition BEMTester.cc:309
static bool fieldsOverlap(const InstructionField &with, unsigned int toFieldWidth, int toFieldPos)
Definition BEMTester.cc:382
static bool conflictsWithGuardEncoding(const GuardField &field, unsigned int encoding, unsigned int width, int offset)
Definition BEMTester.cc:430
static std::tuple< unsigned, unsigned, int > splitEncodingTo(const SocketEncoding &socketEncoding, unsigned encoding, unsigned encodingWidth, int offsetToTarget)
Definition BEMTester.cc:713
static bool conflictsWithDestinationEncodings(const DestinationField &field, unsigned int encoding, unsigned int width, int offset)
Definition BEMTester.cc:560
static int calculateAlignment(unsigned int enc1, unsigned int enc2, const SlotField &field)
Definition BEMTester.cc:352
static bool canAddComponentPriorityEncoding(MoveSlot &slot, unsigned int encoding, unsigned int extraBits, int offset=0)
Definition BEMTester.cc:180
static std::tuple< unsigned, unsigned, int > splitEncoding(unsigned encoding, unsigned encodingWidth, unsigned targetWidth, int offsetToTarget)
Definition BEMTester.cc:677
static bool conflictsWithSocketTableEncodings(const SocketCodeTable &scTable, unsigned int encoding, unsigned int width, int offset)
Definition BEMTester.cc:618
static bool canAddPortEncoding(SocketCodeTable &table, unsigned int encoding, unsigned int extraBits)
Definition BEMTester.cc:247
static unsigned encodingWidth(unsigned encoding, unsigned extrabits)
Definition BEMTools.cc:46
unsigned int extraBits() const
Definition Encoding.cc:119
virtual int width() const
Definition Encoding.cc:130
unsigned int encoding() const
Definition Encoding.cc:108
unsigned int encoding() const
FUGuardEncoding & fuGuardEncoding(int index) const
bool hasUnconditionalGuardEncoding(bool inverted) const
int gprGuardEncodingCount() const
UnconditionalGuardEncoding & unconditionalGuardEncoding(bool inverted) const
GPRGuardEncoding & gprGuardEncoding(int index) const
virtual int width() const
int fuGuardEncodingCount() const
virtual int width() const
virtual int width() const =0
static bool bitFieldsEquals(unsigned enc1, unsigned pos1, unsigned enc2, unsigned pos2, unsigned width)
static unsigned int bitLength(long unsigned int number)
static bool bit(ULongWord integer, unsigned int index)
SourceField & sourceField() const
Definition MoveSlot.cc:277
DestinationField & destinationField() const
Definition MoveSlot.cc:341
virtual int width() const
Definition MoveSlot.cc:406
GuardField & guardField() const
Definition MoveSlot.cc:215
int indexWidth() const
Definition PortCode.cc:215
int encodingWidth() const
Definition PortCode.cc:204
unsigned int extraBits() const
Definition PortCode.cc:177
unsigned int encoding() const
Definition PortCode.cc:164
virtual int width() const
Definition SlotField.cc:307
SocketEncoding & socketEncoding(int index) const
Definition SlotField.cc:170
bool hasNoOperationEncoding() const
Definition SlotField.cc:267
NOPEncoding & noOperationEncoding() const
Definition SlotField.cc:281
BinaryEncoding::Position componentIDPosition() const
Definition SlotField.cc:296
int socketEncodingCount() const
Definition SlotField.cc:156
FUPortCode & fuPortCode(int index) const
int portCodeCount() const
RFPortCode & rfPortCode(int index) const
int fuPortCodeCount() const
PortCode & portCode(int index) const
IUPortCode & iuPortCode(int index) const
int rfPortCodeCount() const
int iuPortCodeCount() const
SocketCodeTable & socketCodes() const
int socketIDWidth() const
int socketIDPosition() const
int socketCodePosition() const
int bridgeEncodingCount() const
virtual int width() const
ImmediateEncoding & immediateEncoding() const
bool hasImmediateEncoding() const
BridgeEncoding & bridgeEncoding(const std::string &bridge) const