jr.sh now asserts the recorded M3 baseline (882-byte .text, 14 JR branches,
2 zero-displacement absolute branches), checks that every JR is one word and
in range, and probes symbolic JRUC with disp 0, disp -128 (widen) and disp
-127 (stay short) through the MC relaxation path.
dis-roundtrip.sh pins the condition code per function again (_sumto LT and
EQ, _max2 GT, _lt LT) instead of the broken ${op#j[ra]} strip, keeping the
global at-least-one-JR check.
native-link.c's far conditional branch now spans ~279 words instead of ~151,
so a small codegen shrink cannot turn it back into a JR.
125 lines
3.6 KiB
C
125 lines
3.6 KiB
C
/* M5 native-link: one translation unit that the native TI-COFF object path
|
|
* must link with a GSPA entry object.
|
|
*
|
|
* native_value() lives in .text and is called from native-entry.asm.
|
|
* msg is a .data pointer to the "native" string; native_first() loads it with
|
|
* a cross-section MOVI, so the object needs a .data symbol relocation.
|
|
* native_combo() calls native_value() and native_first(): both target .text
|
|
* symbols, so those CALLAs are same-section relocations resolved through the
|
|
* 0xFFFF section-relative path. A cross-section CALL would need a second code
|
|
* section, which this writer does not represent; the shared section-symbol
|
|
* relocation path is exercised by the .data and .bss MOVIs instead.
|
|
*/
|
|
|
|
int native_value(void) { return 42; }
|
|
|
|
const char *msg = "native";
|
|
|
|
int native_first(void) { return msg[0]; }
|
|
|
|
/* Element 1 is at a non-zero .bss offset, so the MOVI relocation field is a
|
|
* meaningful bit addend rather than an ambiguous zero. */
|
|
int native_counter[2];
|
|
|
|
int native_bump(void) {
|
|
native_counter[1] = native_counter[1] + 1;
|
|
return native_counter[1];
|
|
}
|
|
|
|
int native_combo(void) { return native_value() + native_first(); }
|
|
|
|
/* A conditional branch and a back edge, so the object carries JAcc/JAUC
|
|
* relocations that GSPLNK must resolve. The in-range branches here are
|
|
* relaxed to the one-word JR form; native_far() below keeps the conditional
|
|
* absolute form covered. */
|
|
int native_loop(int n) {
|
|
int s = 0;
|
|
for (int i = 0; i < n; ++i)
|
|
s += i;
|
|
return s;
|
|
}
|
|
|
|
/* A conditional branch whose target is far outside the 127-word one-word
|
|
* range (about 280 words with 64 volatile reads, so a small codegen change
|
|
* cannot flip it back): the relaxation cannot use JR, so the object still
|
|
* carries a conditional JA<cc> relocation. The volatile loads keep the body
|
|
* from being folded away. */
|
|
volatile int native_probe;
|
|
|
|
int native_far(int a) {
|
|
int s = 0;
|
|
if (a) {
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
s += native_probe;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
/* Defined by native-entry.asm: an undefined C_EXT section-0 symbol plus the
|
|
* text relocation that GSPLNK resolves against the entry object. */
|
|
extern int native_external(int);
|
|
|
|
int native_call_external(void) { return native_external(37); }
|