mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 00:10:31 +00:00
Pay off more technical debt
This makes breaking changes to add underscores to many non-standard
function names provided by the c library. MODE=tiny is now tinier and
we now use smaller locks that are better for tiny apps in this mode.
Some headers have been renamed to be in the same folder as the build
package, so it'll be easier to know which build dependency is needed.
Certain old misguided interfaces have been removed. Intel intrinsics
headers are now listed in libc/isystem (but not in the amalgamation)
to help further improve open source compatibility. Header complexity
has also been reduced. Lastly, more shell scripts are now available.
Compared to 6f7d0cb1c3
, some tiny corrections were made in libc/intrin/g_fds.c and libc/zipos/open.c including double semi colons and incorrect indentation for existing vista changes that were manually pulled from this commit previously.
This commit is contained in:
parent
555260d2e5
commit
7b26b42769
959 changed files with 4065 additions and 4868 deletions
20
third_party/chibicc/asm.c
vendored
20
third_party/chibicc/asm.c
vendored
|
@ -16,6 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/bsf.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "third_party/chibicc/chibicc.h"
|
||||
|
||||
#define PRECIOUS 0b1111000000101000 // bx,bp,r12-r15
|
||||
|
@ -299,7 +301,7 @@ static void PickAsmRegisters(Asm *a) {
|
|||
if (!(m = a->ops[i].regmask)) break;
|
||||
if (popcnt(m) != j) break;
|
||||
if (!(m &= regset)) CouldNotAllocateRegister(&a->ops[i], "rm");
|
||||
pick = 1 << (a->ops[i].reg = bsf(m));
|
||||
pick = 1 << (a->ops[i].reg = _bsf(m));
|
||||
if (pick & PRECIOUS) a->regclob |= pick;
|
||||
regset &= ~pick;
|
||||
a->ops[i].regmask = 0;
|
||||
|
@ -307,14 +309,14 @@ static void PickAsmRegisters(Asm *a) {
|
|||
case kAsmXmm:
|
||||
if (!(m = a->ops[i].regmask)) break;
|
||||
if (!(m &= xmmset)) CouldNotAllocateRegister(&a->ops[i], "xmm");
|
||||
xmmset &= ~(1 << (a->ops[i].reg = bsf(m)));
|
||||
xmmset &= ~(1 << (a->ops[i].reg = _bsf(m)));
|
||||
a->ops[i].regmask = 0;
|
||||
break;
|
||||
case kAsmFpu:
|
||||
if (!(m = a->ops[i].x87mask)) break;
|
||||
if (popcnt(m) != j) break;
|
||||
if (!(m &= x87sts)) CouldNotAllocateRegister(&a->ops[i], "fpu");
|
||||
x87sts &= ~(1 << (a->ops[i].reg = bsf(m)));
|
||||
x87sts &= ~(1 << (a->ops[i].reg = _bsf(m)));
|
||||
a->ops[i].x87mask = 0;
|
||||
break;
|
||||
default:
|
||||
|
@ -368,7 +370,7 @@ static Token *ParseAsmClobbers(Asm *a, Token *tok) {
|
|||
a->flagclob = true;
|
||||
} else if ((i = GetIndexOfRegisterName(s)) != -1) {
|
||||
a->regclob |= 1 << i;
|
||||
} else if (startswith(s, "xmm") && isdigit(s[3]) &&
|
||||
} else if (_startswith(s, "xmm") && isdigit(s[3]) &&
|
||||
(!s[4] || isdigit(s[4]))) {
|
||||
i = s[3] - '0';
|
||||
if (s[4]) {
|
||||
|
@ -379,7 +381,7 @@ static Token *ParseAsmClobbers(Asm *a, Token *tok) {
|
|||
a->xmmclob |= 1 << i;
|
||||
} else if (!strcmp(s, "st")) {
|
||||
a->x87clob |= 1;
|
||||
} else if (startswith(s, "st(") && isdigit(s[3]) && s[4] == ')') {
|
||||
} else if (_startswith(s, "st(") && isdigit(s[3]) && s[4] == ')') {
|
||||
i = s[3] - '0';
|
||||
i &= 7;
|
||||
a->x87clob |= 1 << i;
|
||||
|
@ -538,7 +540,7 @@ static char *HandleAsmSpecifier(Asm *a, char *p) {
|
|||
if ((i = c - '0') >= a->n) {
|
||||
error_tok(a->tok, "bad asm reference at offset %d", p - a->str);
|
||||
}
|
||||
z = bsr(a->ops[i].node->ty->size);
|
||||
z = _bsr(a->ops[i].node->ty->size);
|
||||
if (z > 3 && a->ops[i].type == kAsmReg) {
|
||||
error_tok(a->tok, "bad asm op size");
|
||||
}
|
||||
|
@ -677,7 +679,7 @@ static void StoreAsmOutputs(Asm *a) {
|
|||
println("\tset%s\t(%%rax)", a->ops[i].str + a->ops[i].predicate);
|
||||
break;
|
||||
case kAsmReg:
|
||||
z = bsr(a->ops[i].node->ty->size);
|
||||
z = _bsr(a->ops[i].node->ty->size);
|
||||
if (a->ops[i].reg) {
|
||||
gen_addr(a->ops[i].node);
|
||||
if (z > 3) error_tok(a->tok, "bad asm out size");
|
||||
|
@ -732,7 +734,7 @@ static void StoreAsmOutputs(Asm *a) {
|
|||
static void PushClobbers(Asm *a) {
|
||||
int i, regs = a->regclob & PRECIOUS;
|
||||
while (regs) {
|
||||
i = bsf(regs);
|
||||
i = _bsf(regs);
|
||||
pushreg(kGreg[3][i]);
|
||||
regs &= ~(1 << i);
|
||||
}
|
||||
|
@ -741,7 +743,7 @@ static void PushClobbers(Asm *a) {
|
|||
static void PopClobbers(Asm *a) {
|
||||
int i, regs = a->regclob & PRECIOUS;
|
||||
while (regs) {
|
||||
i = bsr(regs);
|
||||
i = _bsr(regs);
|
||||
popreg(kGreg[3][i]);
|
||||
regs &= ~(1 << i);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue