Commit 014ec632 authored by youngk1019's avatar youngk1019
Browse files

恢复为短跳转

Showing with 249 additions and 15 deletions
+249 -15
......@@ -286,15 +286,15 @@ public abstract class ArmInst implements INodeOwner<ArmInst, ArmBlock> {
}
public boolean needLtorg() {
return (inst.equals(ArmInstKind.MOV) && getOperand(1).IsFImm()) ||
inst.equals(ArmInstKind.Branch) ||
inst.equals(ArmInstKind.Call);
return (inst.equals(ArmInstKind.MOV) && getOperand(1).IsFImm());
// || inst.equals(ArmInstKind.Branch)
// || inst.equals(ArmInstKind.Call);
}
public boolean haveLtorg() {
return (inst.equals(ArmInstKind.Branch) && getCond().equals(ArmCondType.Any)) ||
(inst.equals(ArmInstKind.Return)) ||
(inst.equals(ArmInstKind.Ltorg));
return (inst.equals(ArmInstKind.Branch) && getCond().equals(ArmCondType.Any))
|| (inst.equals(ArmInstKind.Return))
|| (inst.equals(ArmInstKind.Ltorg));
}
public abstract String print();
......
......@@ -28,9 +28,9 @@ public class ArmInstBranch extends ArmInst {
@Override
public String print() {
// String ret = "\t" + "b" + getCond().toString() + "\t" +
String ret = "\t" + "b" + getCond().toString() + "\t" + targetBlock.getLabel() + "\n";
// String ret = "\tldr" + getCond().toString() + "\tpc,\t=" +
// targetBlock.getLabel() + "\n";
String ret = "\tldr" + getCond().toString() + "\tpc,\t=" + targetBlock.getLabel() + "\n";
if (getCond().equals(ArmCondType.Any)) {
ret += ".ltorg\n";
}
......
......@@ -109,14 +109,14 @@ public class ArmInstCall extends ArmInst {
@Override
public String print() {
String ret = "\tmov\tlr,\tpc\n";
if (!StringUtils.isEmpty(funcName)) {
return ret + "\t" + "ldr" + "\tpc,\t=" + funcName + "\n";
}
return ret + "\t" + "ldr" + "\tpc,\t=" + func.getName() + "\n";
// String ret = "\tmov\tlr,\tpc\n";
// if (!StringUtils.isEmpty(funcName)) {
// return "\t" + "bl" + "\t" + funcName + "\n";
// return ret + "\t" + "ldr" + "\tpc,\t=" + funcName + "\n";
// }
// return "\t" + "bl" + "\t" + func.getName() + "\n";
// return ret + "\t" + "ldr" + "\tpc,\t=" + func.getName() + "\n";
if (!StringUtils.isEmpty(funcName)) {
return "\t" + "bl" + "\t" + funcName + "\n";
}
return "\t" + "bl" + "\t" + func.getName() + "\n";
}
}
10
1 106465
4 1
1 317721
1 460929
1 644985
1 84185
1 89851
6 81968
1 492737
5 493598
\ No newline at end of file
106465
84185
492737
0
const int maxn = 100010;
int rt, tot, f[maxn], ch[maxn][2], a[maxn], c[maxn], s[maxn];
void upd(int p) {
s[p] = s[ch[p][0]] + s[ch[p][1]] + c[p];
}
int get(int p) {
if(p == ch[f[p]][1]) {
return 1;
} else {
return 0;
}
}
void clr(int p) {
f[p] = 0;
ch[p][0] = 0;
ch[p][1] = 0;
a[p] = 0;
c[p] = 0;
s[p] = 0;
}
int xor1(int x) {
if(x % 2 == 0){
return x + 1;
} else {
return x - 1;
}
}
void rot(int p) {
int x = f[p], y = f[x], u = get(p), v = get(x);
f[ch[p][xor1(u)]] = x;
ch[x][u] = ch[p][xor1(u)];
f[x] = p;
ch[p][xor1(u)] = x;
upd(x);
upd(p);
f[p] = y;
if (f[p]) ch[y][v] = p;
}
void splay(int p, int g) {
int x = f[p];
while(x != g) {
if (f[x] != g) {
if(get(p) == get(x)) {
rot(x);
} else {
rot(p);
}
}
rot(p);
x = f[p];
}
if(!g) rt = p;
}
void ins(int k) {
if (!rt) {
tot = tot + 1;
rt = tot;
a[rt] = k;
c[tot] = 1;
s[tot] = 1;
return;
}
int x = rt, y = 0;
while (1) {
if (a[x] == k) {
c[x] = c[x] + 1;
s[x] = s[x] + 1;
upd(y);
splay(x, 0);
return;
}
y = x;
if(a[x] < k){
x = ch[x][1];
} else {
x = ch[x][0];
}
if (!x) {
tot = tot + 1;
a[tot] = k;
c[tot] = 1;
s[tot] = 1;
f[tot] = y;
if(a[y] < k) {
ch[y][1] = tot;
} else {
ch[y][0] = tot;
}
upd(y);
splay(tot, 0);
return;
}
}
}
int rank(int k) {
int p = rt, x = 0;
while (1) {
if (k < a[p]) {
if (!ch[p][0]) {
splay(p, 0);
return x + 1;
}
p = ch[p][0];
} else {
x = x + s[ch[p][0]];
if (k == a[p]) {
splay(p, 0);
return x + 1;
}
x = x + c[p];
if (!ch[p][1]) {
splay(p, 0);
return x + 1;
}
p = ch[p][1];
}
}
}
int kth(int k) {
int p = rt;
while (1) {
if (k <= s[ch[p][0]]) p = ch[p][0];
else {
k = k - s[ch[p][0]];
if (k <= c[p]) {
splay(p, 0);
return a[p];
}
k = k - c[p];
p = ch[p][1];
}
}
}
int pre(int k) { return kth(rank(k) - 1); }
int nxt(int k) { return kth(rank(k + 1)); }
void del(int k) {
rank(k);
if (k != a[rt]) return;
if (c[rt] > 1) {
c[rt] = c[rt] - 1;
s[rt] = s[rt] - 1;
return;
}
int p = rt;
if (!ch[p][0] && !ch[p][1]) {
rt = 0;
clr(p);
return;
}
if (!ch[p][0] || !ch[p][1]) {
rt = ch[p][0] + ch[p][1];
f[rt] = 0;
clr(p);
return;
}
pre(k);
f[ch[p][1]] = rt;
ch[rt][1] = ch[p][1];
clr(p);
s[rt] = s[rt] - 1;
return;
}
int t, op, x;
// int getint(){
// int x;
// scanf("%d", &x);
// return x;
// }
// void putint(int x){
// printf("%d",x);
// }
// void putch(int x){
// putchar(x);
// }
int main() {
t = getint();
while (t) {
t = t - 1;
op = getint();
x = getint();
if (op == 1) ins(x);
else if (op == 2) del(x);
else if (op == 3) {
putint(rank(x));
putch(10);
} else if (op == 4) {
putint(kth(x));
putch(10);
} else if (op == 5) {
putint(pre(x));
putch(10);
}else if (op == 6) {
putint(nxt(x));
putch(10);
}
}
return 0;
}
\ No newline at end of file
1
0
int a = 3;
int main(){
if(a){
putint(1);
putch(10);
}else{
putint(0);
putch(10);
}
return 0;
}
\ No newline at end of file
2
0
int a[3] = {1, 2, 3};
int main(){
putint(a[a[0]]);
putch(10);
return 0;
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment