mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-15 05:20:06 +08:00
trivial jump size optimization
This commit is contained in:
parent
1cb355747a
commit
3748975feb
@ -233,7 +233,7 @@ void load(int r, SValue *sv)
|
|||||||
} else if (v == VT_JMP || v == VT_JMPI) {
|
} else if (v == VT_JMP || v == VT_JMPI) {
|
||||||
t = v & 1;
|
t = v & 1;
|
||||||
oad(0xb8 + r, t); /* mov $1, r */
|
oad(0xb8 + r, t); /* mov $1, r */
|
||||||
oad(0xe9, 5); /* jmp after */
|
o(0x05eb); /* jmp after */
|
||||||
gsym(fc);
|
gsym(fc);
|
||||||
oad(0xb8 + r, t ^ 1); /* mov $0, r */
|
oad(0xb8 + r, t ^ 1); /* mov $0, r */
|
||||||
} else if (v != r) {
|
} else if (v != r) {
|
||||||
@ -479,8 +479,15 @@ int gjmp(int t)
|
|||||||
/* generate a jump to a fixed address */
|
/* generate a jump to a fixed address */
|
||||||
void gjmp_addr(int a)
|
void gjmp_addr(int a)
|
||||||
{
|
{
|
||||||
|
int r;
|
||||||
|
r = a - ind - 2;
|
||||||
|
if (r == (char)r) {
|
||||||
|
g(0xeb);
|
||||||
|
g(r);
|
||||||
|
} else {
|
||||||
oad(0xe9, a - ind - 5);
|
oad(0xe9, a - ind - 5);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* generate a test. set 'inv' to invert test. Stack entry is popped */
|
/* generate a test. set 'inv' to invert test. Stack entry is popped */
|
||||||
int gtst(int inv, int t)
|
int gtst(int inv, int t)
|
||||||
|
Loading…
Reference in New Issue
Block a user