本文整理汇总了C++中regalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ regalloc函数的具体用法?C++ regalloc怎么用?C++ regalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了regalloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: udivgen
void
udivgen(Node *l, Node *r, Node *ax, Node *dx)
{
int a, s, t;
uint32 m;
Node nod;
a = udiv(r->vconst, &m, &s, &t);
//print("a=%ud i=%ld p=%d s=%d m=%lux\n", a, (int32)r->vconst, t, s, m);
if(t != 0) {
gins(AMOVL, l, ax);
gins(ASHRL, nodconst(t), ax);
gins(AMOVL, nodconst(m), dx);
gins(AMULL, dx, Z);
}
else if(a) {
if(l->op != OREGISTER) {
regalloc(&nod, l, Z);
gins(AMOVL, l, &nod);
l = &nod;
}
gins(AMOVL, nodconst(m), ax);
gins(AMULL, l, Z);
gins(AADDL, l, dx);
gins(ARCRL, nodconst(1), dx);
if(l == &nod)
regfree(l);
}
else {
gins(AMOVL, nodconst(m), ax);
gins(AMULL, l, Z);
}
if(s != 0)
gins(ASHRL, nodconst(s), dx);
}
示例2: bitstore
void
bitstore(Node *b, Node *n1, Node *n2, Node *n3, Node *nn)
{
int32_t v;
Node nod;
int sh;
regalloc(&nod, b->left, Z);
v = ~0 + (1L << b->type->nbits);
gopcode(OAND, types[TLONG], nodconst(v), n1);
gmove(n1, &nod);
if(nn != Z)
gmove(n1, nn);
sh = b->type->shift;
if(sh > 0)
gopcode(OASHL, types[TLONG], nodconst(sh), &nod);
v <<= sh;
gopcode(OAND, types[TLONG], nodconst(~v), n3);
gopcode(OOR, types[TLONG], n3, &nod);
gmove(&nod, n2);
regfree(&nod);
regfree(n1);
regfree(n2);
regfree(n3);
}
示例3: bitstore
void
bitstore(Node *b, Node *n1, Node *n2, Node *n3, Node *nn)
{
long v;
Node nod, *l;
int sh;
/*
* n1 has adjusted/masked value
* n2 has address of cell
* n3 has contents of cell
*/
l = b->left;
regalloc(&nod, l, Z);
v = ~0 + (1L << b->type->nbits);
gopcode(OAND, nodconst(v), Z, n1);
gopcode(OAS, n1, Z, &nod);
if(nn != Z)
gopcode(OAS, n1, Z, nn);
sh = b->type->shift;
if(sh > 0)
gopcode(OASHL, nodconst(sh), Z, &nod);
v <<= sh;
gopcode(OAND, nodconst(~v), Z, n3);
gopcode(OOR, n3, Z, &nod);
gopcode(OAS, &nod, Z, n2);
regfree(&nod);
regfree(n1);
regfree(n2);
regfree(n3);
}
示例4: swit1
void
swit1(C1 *q, int nc, long def, Node *n)
{
Node tn;
regalloc(&tn, ®node, Z);
swit2(q, nc, def, n, &tn);
regfree(&tn);
}
示例5: bitstore
void
bitstore(Node *b, int n1, int n2, int n3, int result, Node *nn)
{
long v;
Node *l;
Type *t;
int sh, g, gs;
/*
* n1 has adjusted/masked value
* n2 has address of cell
* n3 has contents of cell
*/
t = tfield;
l = b->left;
g = regalloc(t, D_NONE);
v = ~0 + (1L << b->type->nbits);
gopcode(OAND, t, D_CONST, nodconst(v), n1, l);
gmove(t, t, n1, l, g, l);
if(result != D_NONE)
gmove(t, nn->type, n1, l, result, nn);
sh = b->type->shift;
if(sh > 0) {
if(sh >= 8) {
gs = regalloc(t, D_NONE);
gmove(t, t, D_CONST, nodconst(sh), gs, l);
gopcode(OASHL, t, gs, l, g, l);
regfree(gs);
} else
gopcode(OASHL, t, D_CONST, nodconst(sh), g, l);
}
v <<= sh;
gopcode(OAND, t, D_CONST, nodconst(~v), n3, l);
gopcode(OOR, t, n3, l, g, l);
gmove(t, t, g, l, n2|I_INDIR, l);
regfree(g);
regfree(n1);
regfree(n2);
regfree(n3);
}
示例6: sext
void
sext(Node *d, Node *s, Node *l)
{
if(s->reg == D_AX && !nodreg(d, Z, D_DX)) {
reg[D_DX]++;
gins(ACDQ, Z, Z);
}
else {
regalloc(d, l, Z);
gins(AMOVL, s, d);
gins(ASARL, nodconst(31), d);
}
}
示例7: lcgen
void
lcgen(Node *n, Node *nn)
{
Prog *p1;
Node nod;
if(debug['g']) {
prtree(nn, "lcgen lhs");
prtree(n, "lcgen");
}
if(n == Z || n->type == T)
return;
if(nn == Z) {
nn = &nod;
regalloc(&nod, n, Z);
}
switch(n->op) {
default:
if(n->addable < INDEXED) {
diag(n, "unknown op in lcgen: %O", n->op);
break;
}
nod = *n;
nod.op = OADDR;
nod.left = n;
nod.right = Z;
nod.type = types[TIND];
gopcode(OAS, &nod, Z, nn);
break;
case OCOMMA:
cgen(n->left, n->left);
lcgen(n->right, nn);
break;
case OIND:
cgen(n->left, nn);
break;
case OCOND:
bcgen(n->left, 1);
p1 = p;
lcgen(n->right->left, nn);
gbranch(OGOTO);
patch(p1, pc);
p1 = p;
lcgen(n->right->right, nn);
patch(p1, pc);
break;
}
}
示例8: bitload
void
bitload(Node *b, Node *n1, Node *n2, Node *n3, Node *nn)
{
int sh;
int32_t v;
Node *l;
/*
* n1 gets adjusted/masked value
* n2 gets address of cell
* n3 gets contents of cell
*/
l = b->left;
if(n2 != Z) {
regalloc(n1, l, nn);
reglcgen(n2, l, Z);
regalloc(n3, l, Z);
gmove(n2, n3);
gmove(n3, n1);
} else {
regalloc(n1, l, nn);
cgen(l, n1);
}
if(b->type->shift == 0 && typeu[b->type->etype]) {
v = ~0 + (1L << b->type->nbits);
gopcode(OAND, tfield, nodconst(v), n1);
} else {
sh = 32 - b->type->shift - b->type->nbits;
if(sh > 0)
gopcode(OASHL, tfield, nodconst(sh), n1);
sh += b->type->shift;
if(sh > 0)
if(typeu[b->type->etype])
gopcode(OLSHR, tfield, nodconst(sh), n1);
else
gopcode(OASHR, tfield, nodconst(sh), n1);
}
}
示例9: swit1
void
swit1(C1 *q, int nc, int32 def, Node *n)
{
Node nreg;
regalloc(&nreg, n, Z);
if(typev[n->type->etype])
nreg.type = types[TVLONG];
else
nreg.type = types[TLONG];
cgen(n, &nreg);
swit2(q, nc, def, &nreg);
regfree(&nreg);
}
示例10: genasop
static void
genasop(int o, Node *l, Node *r, Node *nn)
{
Node nod, nod1, nod2;
int hardleft;
hardleft = l->addable < INDEXED || l->complex >= FNX;
if(l->complex >= r->complex) {
if(hardleft)
reglcgen(&nod2, l, Z);
else
nod2 = *l;
regalloc(&nod1, r, Z);
cgen(r, &nod1);
} else {
regalloc(&nod1, r, Z);
cgen(r, &nod1);
if(hardleft)
reglcgen(&nod2, l, Z);
else
nod2 = *l;
}
if(nod1.type == nod2.type || !typefd[nod1.type->etype])
regalloc(&nod, &nod2, nn);
else
regalloc(&nod, &nod1, Z);
gmove(&nod2, &nod);
gopcode(o, &nod1, Z, &nod);
gmove(&nod, &nod2);
if(nn != Z)
gmove(&nod2, nn);
regfree(&nod);
regfree(&nod1);
if(hardleft)
regfree(&nod2);
}
示例11: doswit
void
doswit(Node *n)
{
Case *c;
C1 *q, *iq;
long def, nc, i;
Node tn;
def = 0;
nc = 0;
for(c = cases; c->link != C; c = c->link) {
if(c->def) {
if(def)
diag(n, "more than one default in switch");
def = c->label;
continue;
}
nc++;
}
iq = alloc(nc*sizeof(C1));
q = iq;
for(c = cases; c->link != C; c = c->link) {
if(c->def)
continue;
q->label = c->label;
q->val = c->val;
q++;
}
qsort(iq, nc, sizeof(C1), swcmp);
if(debug['W'])
for(i=0; i<nc; i++)
print("case %2ld: = %.8lux\n", i, iq[i].val);
if(def == 0)
def = breakpc;
for(i=0; i<nc-1; i++)
if(iq[i].val == iq[i+1].val)
diag(n, "duplicate cases in switch %ld", iq[i].val);
regalloc(&tn, ®node, Z);
swit1(iq, nc, def, n, &tn);
regfree(&tn);
}
示例12: create_verilog_signal
/*!
* @brief 信号のVerilog HDL生成
*/
int create_verilog_signal()
{
SIGNAL_TREE *now_signal_tree;
char *buf;
char *str;
buf = calloc(STR_MAX, 1);
now_signal_tree = signal_tree_top;
while(now_signal_tree != NULL){
strcpy(buf ,"");
if(
(now_signal_tree->flag == SIGNAL_FLAG_REG) ||
(now_signal_tree->flag == SIGNAL_FLAG_WIRE)
){
switch(now_signal_tree->flag){
case SIGNAL_FLAG_REG:
sprintf(buf, "reg ");
break;
case SIGNAL_FLAG_WIRE:
sprintf(buf, "wire ");
break;
default:
break;
}
if(now_signal_tree->width > 0){
sprintf(buf, "%s[%d:0] ", buf, now_signal_tree->width-1);
}
str = regalloc(now_signal_tree->label);
sprintf(buf, "%s%s;", buf, str);
free(str);
now_signal_tree->verilog = charalloc(buf);
}
now_signal_tree = now_signal_tree->next_ptr;
}
free(buf);
return 0;
}
示例13: _re_comp
int
_re_comp(regexp_t* re, const char* pattern, char* handle, unsigned int size)
{
register Env_t* env = (Env_t*)handle;
register int n;
if (size <= sizeof(Env_t))
return 50;
env->buf = env->cur = (char*)env + sizeof(Env_t);
env->size = size - sizeof(Env_t);
regalloc(env, block, REG_NOFREE);
n = regcomp(&env->re, pattern, REG_LENIENT|REG_NULL);
switch (n)
{
case 0:
break;
case REG_ERANGE:
n = 11;
break;
case REG_BADBR:
n = 16;
break;
case REG_ESUBREG:
n = 25;
break;
case REG_EPAREN:
n = 42;
break;
case REG_EBRACK:
n = 49;
break;
default:
n = 50;
break;
}
re->re_nbra = env->re.re_nsub;
return n;
}
示例14: cgen
void
cgen(Node *n, Node *nn)
{
Node *l, *r;
Prog *p1;
Node nod, nod1, nod2, nod3, nod4;
int o;
long v, curs;
if(debug['g']) {
prtree(nn, "cgen lhs");
prtree(n, "cgen");
}
if(n == Z || n->type == T)
return;
if(typesuv[n->type->etype]) {
sugen(n, nn, n->type->width);
return;
}
l = n->left;
r = n->right;
o = n->op;
if(n->addable >= INDEXED) {
if(nn == Z) {
switch(o) {
default:
nullwarn(Z, Z);
break;
case OINDEX:
nullwarn(l, r);
break;
}
return;
}
gmove(n, nn);
return;
}
curs = cursafe;
if(n->complex >= FNX)
if(l->complex >= FNX)
if(r != Z && r->complex >= FNX)
switch(o) {
default:
regret(&nod, r);
cgen(r, &nod);
regsalloc(&nod1, r);
gopcode(OAS, &nod, Z, &nod1);
regfree(&nod);
nod = *n;
nod.right = &nod1;
cgen(&nod, nn);
return;
case OFUNC:
case OCOMMA:
case OANDAND:
case OOROR:
case OCOND:
case ODOT:
break;
}
switch(o) {
default:
diag(n, "unknown op in cgen: %O", o);
break;
case OAS:
if(l->op == OBIT)
goto bitas;
if(l->addable >= INDEXED && l->complex < FNX) {
if(nn != Z || r->addable < INDEXED) {
if(r->complex >= FNX && nn == Z)
regret(&nod, r);
else
regalloc(&nod, r, nn);
cgen(r, &nod);
gmove(&nod, l);
if(nn != Z)
gmove(&nod, nn);
regfree(&nod);
} else
gmove(r, l);
break;
}
if(l->complex >= r->complex) {
reglcgen(&nod1, l, Z);
if(r->addable >= INDEXED) {
gmove(r, &nod1);
if(nn != Z)
gmove(r, nn);
regfree(&nod1);
break;
}
regalloc(&nod, r, nn);
cgen(r, &nod);
} else {
//.........这里部分代码省略.........
示例15: cgen
void
cgen(Node *n, int result, Node *nn)
{
Node *l, *r, nod;
int lg, rg, xg, yg, g, o;
long v;
Prog *p1;
if(n == Z || n->type == T)
return;
if(typesuv[n->type->etype]) {
sugen(n, result, nn, n->type->width);
return;
}
if(debug['g']) {
if(result == D_TREE)
prtree(nn, "result");
else
print("result = %R\n", result);
prtree(n, "cgen");
}
l = n->left;
r = n->right;
o = n->op;
if(n->addable >= INDEXED) {
if(result == D_NONE) {
if(nn == Z)
switch(o) {
default:
nullwarn(Z, Z);
break;
case OINDEX:
nullwarn(l, r);
break;
}
return;
}
gmove(n->type, nn->type, D_TREE, n, result, nn);
return;
}
v = 0; /* set */
switch(o) {
default:
diag(n, "unknown op in cgen: %O", o);
break;
case OAS:
if(l->op == OBIT)
goto bitas;
/*
* recursive use of result
*/
if(result == D_NONE)
if(l->addable > INDEXED)
if(l->complex < FNX) {
cgen(r, D_TREE, l);
break;
}
/*
* function calls on both sides
*/
if(l->complex >= FNX && r->complex >= FNX) {
cgen(r, D_TOS, r);
v = argoff;
lg = regaddr(result);
lcgen(l, lg, Z);
lg |= I_INDIR;
adjsp(v - argoff);
gmove(r->type, l->type, D_TOS, r, lg, l);
if(result != D_NONE)
gmove(l->type, nn->type, lg, l, result, nn);
regfree(lg);
break;
}
rg = D_TREE;
lg = D_TREE;
if(r->complex >= l->complex) {
/*
* right side before left
*/
if(result != D_NONE) {
rg = regalloc(n->type, result);
cgen(r, rg, n);
} else
if(r->complex >= FNX || r->addable < INDEXED) {
rg = regalloc(r->type, result);
cgen(r, rg, r);
}
if(l->addable < INDEXED) {
lg = regaddr(lg);
lcgen(l, lg, Z);
lg |= I_INDIR;
}
} else {
/*
* left before right
*/
//.........这里部分代码省略.........