56 std::map<TTAProgram::Move*, int> jumpOffsetMoves;
57 std::map<std::shared_ptr<TTAProgram::Immediate>,
int> jumpOffsetLimms;
60 if (!cu->hasOperation(
"reljump")) {
65 auto hwop = cu->operation(
"reljump");
68 auto& ins = procedure[i];
69 for (
int j = 0; j < ins.moveCount(); j++) {
70 auto& m = ins.move(j);
71 auto& src = m.source();
72 auto& dst = m.destination();
73 if (!dst.isFUPort()) {
76 auto& dfu = dst.functionUnit();
80 if (!dst.isOpcodeSetting()) {
83 if (dst.operation().name() !=
"JUMP") {
89 if (src.isInstructionAddress()) {
90 int dstAddr = src.value().intValue();
91 int diff = dstAddr - jumpAddr;
94 if (!bus.signExtends() && diff < 0 && bus.immediateWidth() < 32) {
98 jumpOffsetMoves[&m] = diff;
103 if (src.isImmediateRegister()) {
104 auto& immu = src.immediateUnit();
105 int index =
static_cast<int>(src.index());
107 for (
int k = i - immu.latency(); k >= 0 && !found; k--) {
110 for (
int l = 0; l < immIns.immediateCount(); l++) {
112 if (imm->destination().index() == index &&
113 &imm->destination().immediateUnit() == &immu) {
114 int dstAddr = imm->value().value().intValue();
115 int diff = dstAddr - jumpAddr;
117 if (!immu.signExtends() && diff < 0 && immu.width() < 32) {
122 jumpOffsetLimms[imm] = diff;
128 if (irm.hasReference(immIns)) {
137 for (
auto i : jumpOffsetMoves) {
141 for (
auto i : jumpOffsetLimms) {