1 // CodeGen.spec, created Mon Jun 28 23:00:48 1999 by cananian -*- Java -*- 2 // Copyright (C) 1999 C. Scott Ananian <cananian@alumni.princeton.edu> 3 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 package harpoon.Backend.Sparc; 5 6 import harpoon.ClassFile.HCodeElement; 7 import harpoon.ClassFile.HClass; 8 import harpoon.ClassFile.HMethod; 9 import harpoon.IR.Assem.Instr; 10 import harpoon.IR.Assem.InstrDIRECTIVE; 11 import harpoon.IR.Assem.InstrFactory; 12 import harpoon.IR.Assem.InstrLABEL; 13 import harpoon.IR.Assem.InstrMEM; 14 import harpoon.IR.Tree.ALIGN; 15 import harpoon.IR.Tree.BINOP; 16 import harpoon.IR.Tree.Bop; 17 import harpoon.IR.Tree.CALL; 18 import harpoon.IR.Tree.CJUMP; 19 import harpoon.IR.Tree.CONST; 20 import harpoon.IR.Tree.DATUM; 21 import harpoon.IR.Tree.ESEQ; 22 import harpoon.IR.Tree.EXPR; 23 import harpoon.IR.Tree.INVOCATION; 24 import harpoon.IR.Tree.JUMP; 25 import harpoon.IR.Tree.LABEL; 26 import harpoon.IR.Tree.MEM; 27 import harpoon.IR.Tree.METHOD; 28 import harpoon.IR.Tree.MOVE; 29 import harpoon.IR.Tree.NAME; 30 import harpoon.IR.Tree.NATIVECALL; 31 import harpoon.IR.Tree.RETURN; 32 import harpoon.IR.Tree.SEGMENT; 33 import harpoon.IR.Tree.SEQ; 34 import harpoon.IR.Tree.TEMP; 35 import harpoon.IR.Tree.THROW; 36 import harpoon.IR.Tree.UNOP; 37 import harpoon.IR.Tree.Uop; 38 import harpoon.IR.Tree.Tree; 39 import harpoon.IR.Tree.Type; 40 import harpoon.IR.Tree.Typed; 41 import harpoon.IR.Tree.PreciselyTyped; 42 import harpoon.Temp.Temp; 43 import harpoon.Temp.TempFactory; 44 import harpoon.Temp.TempList; 45 import harpoon.Temp.Label; 46 import harpoon.Temp.LabelList; 47 import harpoon.Util.Util; 48 49 import java.util.Arrays; 50 import java.util.ArrayList; 51 import java.util.List; 52 import java.util.HashMap; 53 import java.util.Map; 54 import java.util.Set; 55 56 /** 57 * <code>Sparc.CodeGen</code> is a code-generator for the Sparc architecture. 58 * 59 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 60 * @author Andrew Berkheimer <andyb@mit.edu> 61 * @version $Id: CodeGen.spec,v 1.5 2004/02/08 01:57:49 cananian Exp $ 62 */ 63 64 public class CodeGen extends harpoon.Backend.Generic.MaxMunchCG { 65 private InstrFactory instrFactory; 66 private final RegFileInfo regfile; 67 private final TempBuilder tb; 68 69 // short variable names for commonly used register temps 70 private Temp[] regg = new Temp[8]; 71 private Temp[] rego = new Temp[8]; 72 private Temp[] regl = new Temp[8]; 73 private Temp[] regi = new Temp[8]; 74 private Temp SP, FP; 75 76 private Map codeGenTempMap; 77 78 public CodeGen(Frame frame) { 79 super(frame); 80 this.regfile = (RegFileInfo) frame.getRegFileInfo(); 81 this.tb = (TempBuilder) frame.getTempBuilder(); 82 for (int i = 0; i < 8; i++) { 83 regg[i] = regfile.getRegister(i); 84 rego[i] = regfile.getRegister(i+8); 85 regl[i] = regfile.getRegister(i+16); 86 regi[i] = regfile.getRegister(i+24); 87 } 88 SP = regfile.SP(); 89 FP = regfile.FP(); 90 } 91 92 // Lots of variations on emit() to make it a bit friendlier 93 // to use in the patterns below. 94 95 // The main variation - this is the only one which should 96 // call emit(Instr) directly - all others should go 97 // through this one. 98 private Instr emit(HCodeElement root, String assem, 99 Temp[] dst, Temp[] src, boolean canFallThrough, 100 List<Label> targets) { 101 return emit(new Instr(instrFactory, root, assem, dst, src, 102 canFallThrough, targets)); 103 } 104 105 private Instr emit(HCodeElement root, String assem, 106 Temp[] dst, Temp[] src) { 107 return emit(root, assem, dst, src, true, null); 108 } 109 110 // emit instructions with targets and that can fall through 111 private Instr emit(HCodeElement root, String assem, 112 Temp[] dst, Temp[] src, Label[] targets) { 113 return emit(root, assem, dst, src, true, Arrays.asList(targets)); 114 } 115 116 // emit instructions with targets and that cannot fall through to 117 // the next instruction - i.e. absolute jumps without any sort 118 // of return address stored somewhere. 119 private Instr emitNoFall(HCodeElement root, String assem, 120 Temp[] dst, Temp[] src, Label[] targets) { 121 return emit(root, assem, dst, src, false, Arrays.asList(targets)); 122 } 123 124 private Instr emitNoFall(HCodeElement root, String assem, 125 Temp[] dst, Temp[] src, List targets) { 126 return emit(root, assem, dst, src, false, targets); 127 } 128 129 private Instr emitMEM(HCodeElement root, String assem, 130 Temp[] dst, Temp[] src) { 131 return emit(new InstrMEM(instrFactory, root, assem, dst, src)); 132 } 133 134 private Instr emitDELAYSLOT(HCodeElement root) { 135 return emit(new InstrDELAYSLOT(instrFactory, root)); 136 } 137 138 private Instr emitCC(HCodeElement root, String assem, 139 Temp[] dst, Temp[] src) { 140 return emit(new InstrCC(instrFactory, root, assem, dst, src)); 141 } 142 143 private Instr emitCC(HCodeElement root, String assem, 144 Temp[] dst, Temp[] src, Label[] targets) { 145 return emit(new InstrCC(instrFactory, root, assem, dst, src, 146 true, Arrays.asList(targets))); 147 } 148 149 private Instr emitCCNoFall(HCodeElement root, String assem, 150 Temp[] dst, Temp[] src, Label[] targets) { 151 return emit(new InstrCC(instrFactory, root, assem, dst, src, 152 false, Arrays.asList(targets))); 153 } 154 155 private Instr emitLABEL(HCodeElement root, String assem, Label label) { 156 return emit(new InstrLABEL(instrFactory, root, assem, label)); 157 } 158 159 private Instr emitDIRECTIVE(HCodeElement root, String directive) { 160 return emit(new InstrDIRECTIVE(instrFactory, root, directive)); 161 } 162 163 private Instr emitENTRY(HCodeElement root) { 164 return emit(new InstrENTRY(instrFactory, root)); 165 } 166 167 private Instr emitEXIT(HCodeElement root) { 168 return emit(new InstrEXIT(instrFactory, root)); 169 } 170 171 private Temp makeTemp(Typed ROOT, Temp orig, TempFactory tf) { 172 Temp newTemp = (Temp) codeGenTempMap.get(orig); 173 if (newTemp == null) { 174 newTemp = tb.makeTemp(ROOT, tf); 175 codeGenTempMap.put(orig, newTemp); 176 } 177 return newTemp; 178 } 179 180 private void emitCallPrologue(HCodeElement ROOT, TempList arglist, 181 Label handler, boolean passhandler) { 182 /* AAA - currently only deals with up to 6 arguments */ 183 TempList argrev = null; 184 int wordsused = 0; 185 186 // count number of words required by arguments and 187 // reverse the argument lists. 188 for (TempList tl = arglist; tl != null; tl = tl.tail) { 189 argrev = new TempList(tl.head, argrev); 190 wordsused += tb.isTwoWord(tl.head) ? 2 : 1; 191 } 192 193 // Add one more word used - to pass exceptional return address 194 if (passhandler) { 195 wordsused++; 196 } 197 198 // move arguments into place 199 for (TempList tl = argrev; tl != null; tl = tl.tail) { 200 Temp temp = tl.head; 201 if (tb.isTwoWord(temp)) { 202 if (wordsused > 7) { /* two stack */ 203 assert false : ("emitCallPrologue: too many arguments"); 204 } else if (wordsused == 7) { /* one reg, one stack */ 205 assert false : ("emitCallPrologue: too many arguments"); 206 } else { /* two reg */ 207 declare(rego[wordsused - 2], HClass.Void); 208 declare(rego[wordsused - 1], HClass.Void); 209 emit (ROOT, "mov `s0h, `d0", 210 new Temp[] { rego[wordsused - 2] }, 211 new Temp[] { temp }); 212 emit (ROOT, "mov `s0l, `d0", 213 new Temp[] { rego[wordsused - 1] }, 214 new Temp[] { temp }); 215 } 216 wordsused -= 2; 217 } else { 218 if (wordsused > 6) { /* on stack */ 219 assert false : ("emitCallPrologue: too many arguments"); 220 } else { /* in reg */ 221 declare(rego[wordsused - 1], HClass.Void); 222 emit (ROOT, "mov `s0, `d0", 223 new Temp[] { rego[wordsused - 1] }, 224 new Temp[] { temp }); 225 } 226 wordsused--; 227 } 228 } 229 230 // Put the excceptional return address in %o0 231 if (passhandler) { 232 declare(rego[0], HClass.Void); 233 emit (ROOT, "set "+handler+", `d0", 234 new Temp[] { rego[0] }, 235 new Temp[] { }); 236 wordsused--; 237 } 238 239 assert wordsused == 0 : ("emitCallPrologue: all args not in place"); 240 } 241 242 private void emitCallEpilogue(INVOCATION ROOT, Temp retval, HClass type) { 243 /* AAA - need to adjust SP if args were put on stack */ 244 245 if (ROOT.getRetval() == null) { 246 // don't bother emiting move for void methods 247 } else if (ROOT.getRetval().isDoubleWord()) { 248 declare(retval, type); 249 emit (ROOT, "mov `s0, `d0h", 250 new Temp[] { retval }, 251 new Temp[] { rego[0] }); 252 emit (ROOT, "mov `s0, `d0l", 253 new Temp[] { retval }, 254 new Temp[] { rego[1] }); 255 } else { 256 declare(retval, type); 257 emit (ROOT, "mov `s0, `d0", 258 new Temp[] { retval }, 259 new Temp[] { rego[0] }); 260 } 261 } 262 263 private void emitCallFixupTable(HCodeElement ROOT, Label norm, Label exc) { 264 emitDIRECTIVE (ROOT, ".text 10\t! .section fixup"); 265 emitDIRECTIVE (ROOT, "\t.word "+norm+", "+exc); 266 emitDIRECTIVE (ROOT, ".text 0 \t! .section code"); 267 } 268 269 private void emitHandlerStub(HCodeElement ROOT, Temp retex, Label handler) { 270 if (tb.isTwoWord(retex)) { 271 declare(rego[0], HClass.Void); 272 declare(rego[1], HClass.Void); 273 emit (ROOT, "mov `s0h, `d0", 274 new Temp[] { retex }, 275 new Temp[] { rego[0] }); 276 emit (ROOT, "mov `s0l, `d0", 277 new Temp[] { retex }, 278 new Temp[] { rego[1] }); 279 } else { 280 declare(rego[0], HClass.Void); 281 emit (ROOT, "mov `s0, `d0", 282 new Temp[] { retex }, 283 new Temp[] { rego[0] }); 284 } 285 emitNoFall (ROOT, "ba " + handler, null, null, new Label[] { handler }); 286 } 287 288 public Instr procFixup(HMethod hm, Instr instr, int stackspace, 289 Set usedRegisters) { 290 InstrFactory inf = instrFactory; // convenient abbreviation. 291 Label methodlabel = frame.getRuntime().getNameMap().label(hm); 292 293 for (Instr i = instr; i != null; i = i.getNext()) { 294 if (i instanceof InstrENTRY) { // entry stub 295 Instr in1 = new InstrDIRECTIVE(inf, i, "\t.align 4"); 296 Instr in2 = new InstrDIRECTIVE(inf, i, "\t.global " + 297 methodlabel.name); 298 Instr in3 = new InstrDIRECTIVE(inf, i, "\t.type " + 299 methodlabel.name +",#function"); 300 Instr in4 = new InstrLABEL(inf, i, methodlabel.name+":", 301 methodlabel); 302 303 /* AAA - the 92 assumes no more than 6 args I think */ 304 int save_offset = 92 + 4 * stackspace; 305 306 // save clobbers just about everything 307 List save_clob = new ArrayList(); 308 save_clob.addAll(Arrays.asList(regi)); 309 save_clob.addAll(Arrays.asList(regl)); 310 save_clob.addAll(Arrays.asList(rego)); 311 Instr in5 = new Instr(inf, i, 312 "save %sp, -" + save_offset + ", %sp", 313 (Temp[])save_clob.toArray(new Temp[24]), 314 rego); 315 in5.layout(i, i.getNext()); 316 in4.layout(i, in5); 317 in3.layout(i, in4); 318 in2.layout(i, in3); 319 in1.layout(i, in2); 320 if (i == instr) instr = in1; 321 i.remove(); i = in1; 322 } 323 if (i instanceof InstrEXIT) { // exit stub 324 // ret == jmpl %i7 + 8, %g0 325 Instr in1 = new Instr(inf, i, "ret", 326 null, new Temp[] { regi[7] }); 327 328 List restore_clobbers = new ArrayList(); 329 restore_clobbers.addAll(Arrays.asList(regi)); 330 restore_clobbers.addAll(Arrays.asList(regl)); 331 restore_clobbers.addAll(Arrays.asList(rego)); 332 Instr in2 = new Instr(inf, i, "restore", 333 (Temp[])restore_clobbers.toArray(new Temp[24]), 334 regi); 335 in1.layout(i.getPrev(), i); 336 in2.layout(in1, i); 337 i.remove(); 338 i = in2; 339 } 340 } 341 return instr; 342 } 343 344 // INNER CLASSES 345 346 /** Sub-class to represent delay-slots. 347 * <code>optimize()</code> uses this class information to determine that 348 * it should rearrange code to try to eliminate these instructions. 349 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 350 * @see Sparc.CodeGen#optimize 351 */ 352 public class InstrDELAYSLOT extends Instr { 353 // a nop to fill the delay slot 354 public InstrDELAYSLOT(InstrFactory inf, HCodeElement source) { 355 super(inf, source, "nop ! delay slot"); 356 } 357 } 358 359 /** Sub-class to indicate dependencies on the condition code register 360 * for later optimization. This prevents putting the <code>cmp</code> 361 * instruction in the delay-slot of its branch-conditional. 362 */ 363 public class InstrCC extends Instr { 364 //a new instr type to indicate dependency on the condition code reg 365 public InstrCC(InstrFactory inf, HCodeElement source, String assem, 366 Temp[] dst, Temp[] src) { 367 super(inf, source, assem, dst, src); 368 } 369 370 public InstrCC(InstrFactory inf, HCodeElement source, String assem, 371 Temp[] dst, Temp[] src, boolean canFallThrough, 372 List<Label> targets) { 373 super(inf, source, assem, dst, src, canFallThrough, targets); 374 } 375 } 376 377 private class InstrENTRY extends InstrDIRECTIVE { 378 public InstrENTRY(InstrFactory inf, HCodeElement src) { 379 super(inf, src, "!--method entry point--"); 380 } 381 } 382 383 private class InstrEXIT extends InstrDIRECTIVE { 384 public InstrEXIT(InstrFactory inf, HCodeElement src) { 385 super(inf, src, "!--method exit point--"); 386 } 387 } 388 389 /** Determine whether a constant can fit in the immediate field of 390 * a SPARC instruction. */ 391 static boolean is13bit(Number n) { 392 if (n instanceof Double || n instanceof Float) return false; 393 return ((-4096<=n.longValue()) && (n.longValue()<=4095)); 394 } 395 396 static String storeSuffix(MEM mem) { 397 String r = ""; 398 if (mem.isSmall()) { 399 switch (mem.bitwidth()) { 400 case 8: r += "b"; break; 401 case 16: r += "h"; break; 402 } 403 } else { 404 if (mem.isDoubleWord()) r += "d"; 405 /* should always use ld and ldd - as figures out floating 406 * point by looking at registers in instruction. 407 * if (mem.isFloatingPoint()) r += "f"; */ 408 } 409 return r; 410 } 411 412 static String loadSuffix(MEM mem) { 413 String r = ""; 414 if (mem.isSmall()) { 415 r += (mem.signed()) ? "s" : "u"; 416 switch (mem.bitwidth()) { 417 case 8: r += "b"; break; 418 case 16: r += "h"; break; 419 } 420 } else { 421 if (mem.isDoubleWord()) r += "d"; 422 /* should always use ld and ldd - as figures out floating 423 * point by looking at registers in instruction. 424 * if (mem.isFloatingPoint()) r += "f"; */ 425 } 426 return r; 427 } 428 429 /** Crunch simple <code>Bop</code>'s down to sparc instruction. */ 430 static String bop(int op) { 431 switch(op) { 432 case Bop.ADD: return "add"; 433 case Bop.AND: return "and"; 434 case Bop.OR: return "or"; 435 case Bop.XOR: return "xor"; 436 case Bop.SHL: return "sll"; 437 case Bop.SHR: return "sra"; 438 case Bop.USHR:return "srl"; 439 } 440 assert false; 441 return null; 442 } 443 444 static boolean isCommutative(int op) { 445 return op==Bop.ADD || op==Bop.OR || op==Bop.AND || op==Bop.XOR; 446 } 447 448 static boolean isShift(int op) { 449 return op==Bop.SHL || op==Bop.SHR || op==Bop.USHR; 450 } 451 452 private static boolean __CommExp__isCommutative(int op) { 453 switch(op) { 454 case harpoon.IR.Tree.Bop.CMPGT: 455 case harpoon.IR.Tree.Bop.CMPGE: 456 case harpoon.IR.Tree.Bop.CMPLE: 457 case harpoon.IR.Tree.Bop.CMPLT: return true; 458 default: return harpoon.IR.Tree.Bop.isCommutative(op); 459 } 460 } 461 private static int __CommExp__swapCmpOp(int op) { 462 switch(op) { 463 case harpoon.IR.Tree.Bop.CMPGT:return harpoon.IR.Tree.Bop.CMPLT; 464 case harpoon.IR.Tree.Bop.CMPGE:return harpoon.IR.Tree.Bop.CMPLE; 465 case harpoon.IR.Tree.Bop.CMPLE:return harpoon.IR.Tree.Bop.CMPGE; 466 case harpoon.IR.Tree.Bop.CMPLT:return harpoon.IR.Tree.Bop.CMPGT; 467 default: return op; 468 } 469 } 470 471 472 /** Generates assembly code from a <code>harpoon.IR.Tree.Code</code>. 473 <BR> <B>modifies:</B> <code>this</code> 474 <BR> <B>effects:</B> 475 Scans <code>tree</code> to find a tiling of 476 Instruction Patterns, calling auxillary methods 477 and data structures as defined in the .spec file. 478 Generates an associated <code>Derivation</code> 479 object as the second element of the returned 480 <code>List</code>. 481 @param tree Set of abstract <code>Tree</code> instructions 482 that form the body of the procedure being compiled. 483 */ 484 public final java.util.List cgg_genCode(final harpoon.IR.Tree.Code code, final harpoon.IR.Assem.InstrFactory inf) { 485 _methodPrologue_(inf); 486 487 // State Variables which are initialized each 488 // time we do instruction selection on another 489 // bit of TreeCode 490 491 this.instrFactory = inf; 492 codeGenTempMap = new HashMap(); 493 494 final class CggVisitor extends harpoon.IR.Tree.TreeVisitor { 495 harpoon.Temp.Temp munchExp(harpoon.IR.Tree.Exp expArg) { 496 boolean _matched_ = false; 497 clearDecl(); // reset temp type mappings 498 /* MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(PLUS,e1,CONST<i>(c))) */ 499 if (true 500 // check expression type 501 && expArg instanceof harpoon.IR.Tree.MEM 502 // check operand types 503 && ( 504 expArg.type() == Type.DOUBLE || 505 expArg.type() == Type.FLOAT || 506 expArg.type() == Type.LONG || 507 expArg.type() == Type.POINTER || 508 ( expArg.type() == Type.INT && ! 509 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 510 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 511 (((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall() && ( 512 ((harpoon.IR.Tree.PreciselyTyped)expArg).signed() ? ( 513 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 514 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 515 false) : ( 516 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 517 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 518 false) ) ) || 519 false ) 520 // end check operand types 521 // check child 522 // check expression type 523 && ((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.BINOP 524 // check operand types 525 && ( 526 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.DOUBLE || 527 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.FLOAT || 528 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.LONG || 529 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.POINTER || 530 ( ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.INT && ! 531 (((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 532 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)expArg).getExp()).isSmall())) || 533 false ) 534 // end check operand types 535 // check left child 536 // no check needed for ExpId children 537 // check right child 538 // check expression type 539 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight() instanceof harpoon.IR.Tree.CONST 540 // check operand types 541 && ( 542 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight().type() == Type.INT && ! 543 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 544 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight()).isSmall())) || 545 false ) 546 // end check operand types 547 ){ 548 int PLUS = ((harpoon.IR.Tree.BINOP) ((harpoon.IR.Tree.MEM)expArg).getExp()).op; 549 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight()).value; 550 harpoon.IR.Tree.MEM ROOT = (harpoon.IR.Tree.MEM) expArg; 551 _matched_ = true&& (__CommExp__isCommutative(PLUS=__CommExp__swapCmpOp(PLUS))); 552 553 if (_matched_) { // action code! degree: 3 554 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft()); 555 556 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 557 clearDecl(); 558 declare(r, code.getTreeDerivation(), ROOT); 559 560 String srcsuff = (ROOT.isDoubleWord()) ? "h" : ""; 561 emit (ROOT, "ld"+loadSuffix(ROOT) + " [ `s0 + "+c+" ], `d0"+srcsuff + "", 562 new Temp[] { r }, new Temp[] { e1 }); 563 return r; 564 } 565 } 566 /* MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(PLUS,CONST<i>(c),e1)) */ 567 if (true 568 // check expression type 569 && expArg instanceof harpoon.IR.Tree.MEM 570 // check operand types 571 && ( 572 expArg.type() == Type.DOUBLE || 573 expArg.type() == Type.FLOAT || 574 expArg.type() == Type.LONG || 575 expArg.type() == Type.POINTER || 576 ( expArg.type() == Type.INT && ! 577 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 578 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 579 (((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall() && ( 580 ((harpoon.IR.Tree.PreciselyTyped)expArg).signed() ? ( 581 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 582 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 583 false) : ( 584 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 585 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 586 false) ) ) || 587 false ) 588 // end check operand types 589 // check child 590 // check expression type 591 && ((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.BINOP 592 // check operand types 593 && ( 594 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.DOUBLE || 595 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.FLOAT || 596 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.LONG || 597 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.POINTER || 598 ( ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.INT && ! 599 (((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 600 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)expArg).getExp()).isSmall())) || 601 false ) 602 // end check operand types 603 // check left child 604 // check expression type 605 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft() instanceof harpoon.IR.Tree.CONST 606 // check operand types 607 && ( 608 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft().type() == Type.INT && ! 609 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft() instanceof harpoon.IR.Tree.PreciselyTyped && 610 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft()).isSmall())) || 611 false ) 612 // end check operand types 613 // check right child 614 // no check needed for ExpId children 615 ){ 616 int PLUS = ((harpoon.IR.Tree.BINOP) ((harpoon.IR.Tree.MEM)expArg).getExp()).op; 617 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft()).value; 618 harpoon.IR.Tree.MEM ROOT = (harpoon.IR.Tree.MEM) expArg; 619 _matched_ = true; 620 621 if (_matched_) { // action code! degree: 3 622 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight()); 623 624 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 625 clearDecl(); 626 declare(r, code.getTreeDerivation(), ROOT); 627 628 String srcsuff = (ROOT.isDoubleWord()) ? "h" : ""; 629 emit (ROOT, "ld"+loadSuffix(ROOT) + " [ `s0 + "+c+" ], `d0"+srcsuff + "", 630 new Temp[] { r }, new Temp[] { e1 }); 631 return r; 632 } 633 } 634 /* MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(PLUS,CONST<i>(c),e1)) */ 635 if (true 636 // check expression type 637 && expArg instanceof harpoon.IR.Tree.MEM 638 // check operand types 639 && ( 640 expArg.type() == Type.DOUBLE || 641 expArg.type() == Type.FLOAT || 642 expArg.type() == Type.LONG || 643 expArg.type() == Type.POINTER || 644 ( expArg.type() == Type.INT && ! 645 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 646 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 647 (((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall() && ( 648 ((harpoon.IR.Tree.PreciselyTyped)expArg).signed() ? ( 649 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 650 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 651 false) : ( 652 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 653 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 654 false) ) ) || 655 false ) 656 // end check operand types 657 // check child 658 // check expression type 659 && ((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.BINOP 660 // check operand types 661 && ( 662 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.DOUBLE || 663 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.FLOAT || 664 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.LONG || 665 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.POINTER || 666 ( ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.INT && ! 667 (((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 668 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)expArg).getExp()).isSmall())) || 669 false ) 670 // end check operand types 671 // check left child 672 // check expression type 673 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft() instanceof harpoon.IR.Tree.CONST 674 // check operand types 675 && ( 676 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft().type() == Type.INT && ! 677 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft() instanceof harpoon.IR.Tree.PreciselyTyped && 678 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft()).isSmall())) || 679 false ) 680 // end check operand types 681 // check right child 682 // no check needed for ExpId children 683 ){ 684 int PLUS = ((harpoon.IR.Tree.BINOP) ((harpoon.IR.Tree.MEM)expArg).getExp()).op; 685 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft()).value; 686 harpoon.IR.Tree.MEM ROOT = (harpoon.IR.Tree.MEM) expArg; 687 _matched_ = true&& (__CommExp__isCommutative(PLUS=__CommExp__swapCmpOp(PLUS))); 688 689 if (_matched_) { // action code! degree: 3 690 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight()); 691 692 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 693 clearDecl(); 694 declare(r, code.getTreeDerivation(), ROOT); 695 696 String srcsuff = (ROOT.isDoubleWord()) ? "h" : ""; 697 emit (ROOT, "ld"+loadSuffix(ROOT) + " [ `s0 + "+c+" ], `d0"+srcsuff + "", 698 new Temp[] { r }, new Temp[] { e1 }); 699 return r; 700 } 701 } 702 /* MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(PLUS,e1,CONST<i>(c))) */ 703 if (true 704 // check expression type 705 && expArg instanceof harpoon.IR.Tree.MEM 706 // check operand types 707 && ( 708 expArg.type() == Type.DOUBLE || 709 expArg.type() == Type.FLOAT || 710 expArg.type() == Type.LONG || 711 expArg.type() == Type.POINTER || 712 ( expArg.type() == Type.INT && ! 713 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 714 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 715 (((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall() && ( 716 ((harpoon.IR.Tree.PreciselyTyped)expArg).signed() ? ( 717 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 718 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 719 false) : ( 720 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 721 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 722 false) ) ) || 723 false ) 724 // end check operand types 725 // check child 726 // check expression type 727 && ((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.BINOP 728 // check operand types 729 && ( 730 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.DOUBLE || 731 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.FLOAT || 732 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.LONG || 733 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.POINTER || 734 ( ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.INT && ! 735 (((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 736 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)expArg).getExp()).isSmall())) || 737 false ) 738 // end check operand types 739 // check left child 740 // no check needed for ExpId children 741 // check right child 742 // check expression type 743 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight() instanceof harpoon.IR.Tree.CONST 744 // check operand types 745 && ( 746 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight().type() == Type.INT && ! 747 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 748 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight()).isSmall())) || 749 false ) 750 // end check operand types 751 ){ 752 int PLUS = ((harpoon.IR.Tree.BINOP) ((harpoon.IR.Tree.MEM)expArg).getExp()).op; 753 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight()).value; 754 harpoon.IR.Tree.MEM ROOT = (harpoon.IR.Tree.MEM) expArg; 755 _matched_ = true; 756 757 if (_matched_) { // action code! degree: 3 758 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft()); 759 760 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 761 clearDecl(); 762 declare(r, code.getTreeDerivation(), ROOT); 763 764 String srcsuff = (ROOT.isDoubleWord()) ? "h" : ""; 765 emit (ROOT, "ld"+loadSuffix(ROOT) + " [ `s0 + "+c+" ], `d0"+srcsuff + "", 766 new Temp[] { r }, new Temp[] { e1 }); 767 return r; 768 } 769 } 770 /* BINOP<i,p>(op,CONST<i,l,f,d,p>(c),e) */ 771 if (true 772 // check expression type 773 && expArg instanceof harpoon.IR.Tree.BINOP 774 // check operand types 775 && ( 776 expArg.type() == Type.POINTER || 777 ( expArg.type() == Type.INT && ! 778 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 779 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 780 false ) 781 // end check operand types 782 // check left child 783 // check expression type 784 && ((harpoon.IR.Tree.BINOP)expArg).getLeft() instanceof harpoon.IR.Tree.CONST 785 // check operand types 786 && ( 787 ((harpoon.IR.Tree.BINOP)expArg).getLeft().type() == Type.DOUBLE || 788 ((harpoon.IR.Tree.BINOP)expArg).getLeft().type() == Type.FLOAT || 789 ((harpoon.IR.Tree.BINOP)expArg).getLeft().type() == Type.LONG || 790 ((harpoon.IR.Tree.BINOP)expArg).getLeft().type() == Type.POINTER || 791 ( ((harpoon.IR.Tree.BINOP)expArg).getLeft().type() == Type.INT && ! 792 (((harpoon.IR.Tree.BINOP)expArg).getLeft() instanceof harpoon.IR.Tree.PreciselyTyped && 793 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)expArg).getLeft()).isSmall())) || 794 false ) 795 // end check operand types 796 // check right child 797 // no check needed for ExpId children 798 ){ 799 int op = ((harpoon.IR.Tree.BINOP) expArg).op; 800 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)expArg).getLeft()).value; 801 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 802 _matched_ = true&& ( isCommutative(op) && is13bit(c) ); 803 804 if (_matched_) { // action code! degree: 2 805 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 806 807 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 808 clearDecl(); 809 declare(r, code.getTreeDerivation(), ROOT); 810 811 emit (ROOT, bop(op)+" `s0, "+c+", `d0", 812 new Temp[] { r }, new Temp[] { e }); 813 return r; 814 } 815 } 816 /* BINOP<i,p>(op,e,CONST<i,l,f,d,p>(c)) */ 817 if (true 818 // check expression type 819 && expArg instanceof harpoon.IR.Tree.BINOP 820 // check operand types 821 && ( 822 expArg.type() == Type.POINTER || 823 ( expArg.type() == Type.INT && ! 824 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 825 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 826 false ) 827 // end check operand types 828 // check left child 829 // no check needed for ExpId children 830 // check right child 831 // check expression type 832 && ((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.CONST 833 // check operand types 834 && ( 835 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.DOUBLE || 836 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.FLOAT || 837 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.LONG || 838 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.POINTER || 839 ( ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.INT && ! 840 (((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 841 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)expArg).getRight()).isSmall())) || 842 false ) 843 // end check operand types 844 ){ 845 int op = ((harpoon.IR.Tree.BINOP) expArg).op; 846 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)expArg).getRight()).value; 847 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 848 _matched_ = true&& ( (isShift(op) || isCommutative(op)) && is13bit(c) ); 849 850 if (_matched_) { // action code! degree: 2 851 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 852 853 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 854 clearDecl(); 855 declare(r, code.getTreeDerivation(), ROOT); 856 857 emit (ROOT, bop(op)+" `s0, "+c+", `d0", 858 new Temp[] { r }, new Temp[] { e }); 859 return r; 860 } 861 } 862 /* BINOP<i,p>(ADD,e1,UNOP<i,l,f,d,p>(NEG,e2)) */ 863 if (true 864 // check expression type 865 && expArg instanceof harpoon.IR.Tree.BINOP 866 // check opcode 867 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.ADD 868 // check operand types 869 && ( 870 expArg.type() == Type.POINTER || 871 ( expArg.type() == Type.INT && ! 872 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 873 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 874 false ) 875 // end check operand types 876 // check left child 877 // no check needed for ExpId children 878 // check right child 879 // check expression type 880 && ((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.UNOP 881 // check opcode 882 && ((harpoon.IR.Tree.UNOP)((harpoon.IR.Tree.BINOP)expArg).getRight()).op == harpoon.IR.Tree.Uop.NEG 883 // check operand types 884 && ( 885 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.DOUBLE || 886 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.FLOAT || 887 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.LONG || 888 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.POINTER || 889 ( ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.INT && ! 890 (((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 891 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)expArg).getRight()).isSmall())) || 892 false ) 893 // end check operand types 894 // check child 895 // no check needed for ExpId children 896 ){ 897 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 898 _matched_ = true; 899 900 if (_matched_) { // action code! degree: 2 901 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 902 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.UNOP)((harpoon.IR.Tree.BINOP)expArg).getRight()).getOperand()); 903 904 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 905 clearDecl(); 906 declare(r, code.getTreeDerivation(), ROOT); 907 908 emit (ROOT, "sub `s0, `s1, `d0", 909 new Temp[] { r }, new Temp[] { e1, e2 }); 910 return r; 911 } 912 } 913 /* BINOP<l>(ADD,e1,UNOP<i,l,f,d,p>(NEG,e2)) */ 914 if (true 915 // check expression type 916 && expArg instanceof harpoon.IR.Tree.BINOP 917 // check opcode 918 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.ADD 919 // check operand types 920 && ( 921 expArg.type() == Type.LONG || 922 false ) 923 // end check operand types 924 // check left child 925 // no check needed for ExpId children 926 // check right child 927 // check expression type 928 && ((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.UNOP 929 // check opcode 930 && ((harpoon.IR.Tree.UNOP)((harpoon.IR.Tree.BINOP)expArg).getRight()).op == harpoon.IR.Tree.Uop.NEG 931 // check operand types 932 && ( 933 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.DOUBLE || 934 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.FLOAT || 935 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.LONG || 936 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.POINTER || 937 ( ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.INT && ! 938 (((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 939 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)expArg).getRight()).isSmall())) || 940 false ) 941 // end check operand types 942 // check child 943 // no check needed for ExpId children 944 ){ 945 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 946 _matched_ = true; 947 948 if (_matched_) { // action code! degree: 2 949 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 950 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.UNOP)((harpoon.IR.Tree.BINOP)expArg).getRight()).getOperand()); 951 952 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 953 clearDecl(); 954 declare(r, code.getTreeDerivation(), ROOT); 955 956 emitCC (ROOT, "subcc `s0l, `s1l, `d0l", 957 new Temp[] { r }, new Temp[] { e1, e2 }); 958 emitCC (ROOT, "subx `s0h, `s1h, `d0h", 959 new Temp[] { r }, new Temp[] { e1, e2 }); 960 return r; 961 } 962 } 963 /* BINOP<f,d>(ADD,e1,UNOP<i,l,f,d,p>(NEG,e2)) */ 964 if (true 965 // check expression type 966 && expArg instanceof harpoon.IR.Tree.BINOP 967 // check opcode 968 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.ADD 969 // check operand types 970 && ( 971 expArg.type() == Type.DOUBLE || 972 expArg.type() == Type.FLOAT || 973 false ) 974 // end check operand types 975 // check left child 976 // no check needed for ExpId children 977 // check right child 978 // check expression type 979 && ((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.UNOP 980 // check opcode 981 && ((harpoon.IR.Tree.UNOP)((harpoon.IR.Tree.BINOP)expArg).getRight()).op == harpoon.IR.Tree.Uop.NEG 982 // check operand types 983 && ( 984 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.DOUBLE || 985 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.FLOAT || 986 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.LONG || 987 ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.POINTER || 988 ( ((harpoon.IR.Tree.BINOP)expArg).getRight().type() == Type.INT && ! 989 (((harpoon.IR.Tree.BINOP)expArg).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 990 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)expArg).getRight()).isSmall())) || 991 false ) 992 // end check operand types 993 // check child 994 // no check needed for ExpId children 995 ){ 996 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 997 _matched_ = true; 998 999 if (_matched_) { // action code! degree: 2 1000 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1001 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.UNOP)((harpoon.IR.Tree.BINOP)expArg).getRight()).getOperand()); 1002 1003 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1004 clearDecl(); 1005 declare(r, code.getTreeDerivation(), ROOT); 1006 1007 String s = (ROOT.isDoubleWord()) ? "d" : "s"; 1008 emit (ROOT, "fsub"+s+" `s0, `s1, `d0", 1009 new Temp[] { r }, new Temp[] { e1, e2 }); 1010 return r; 1011 } 1012 } 1013 /* MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(PLUS,e1,e2)) */ 1014 if (true 1015 // check expression type 1016 && expArg instanceof harpoon.IR.Tree.MEM 1017 // check operand types 1018 && ( 1019 expArg.type() == Type.DOUBLE || 1020 expArg.type() == Type.FLOAT || 1021 expArg.type() == Type.LONG || 1022 expArg.type() == Type.POINTER || 1023 ( expArg.type() == Type.INT && ! 1024 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1025 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1026 (((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall() && ( 1027 ((harpoon.IR.Tree.PreciselyTyped)expArg).signed() ? ( 1028 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 1029 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 1030 false) : ( 1031 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 1032 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 1033 false) ) ) || 1034 false ) 1035 // end check operand types 1036 // check child 1037 // check expression type 1038 && ((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.BINOP 1039 // check operand types 1040 && ( 1041 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.DOUBLE || 1042 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.FLOAT || 1043 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.LONG || 1044 ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.POINTER || 1045 ( ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.INT && ! 1046 (((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 1047 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)expArg).getExp()).isSmall())) || 1048 false ) 1049 // end check operand types 1050 // check left child 1051 // no check needed for ExpId children 1052 // check right child 1053 // no check needed for ExpId children 1054 ){ 1055 int PLUS = ((harpoon.IR.Tree.BINOP) ((harpoon.IR.Tree.MEM)expArg).getExp()).op; 1056 harpoon.IR.Tree.MEM ROOT = (harpoon.IR.Tree.MEM) expArg; 1057 _matched_ = true; 1058 1059 if (_matched_) { // action code! degree: 2 1060 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getLeft()); 1061 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)expArg).getExp()).getRight()); 1062 1063 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1064 clearDecl(); 1065 declare(r, code.getTreeDerivation(), ROOT); 1066 1067 String srcsuff = (ROOT.isDoubleWord()) ? "h" : ""; 1068 emit (ROOT, "ld"+loadSuffix(ROOT) + " [ `s0 + `s1 ], `d0"+srcsuff + "", 1069 new Temp[] { r }, new Temp[] { e1, e2 }); 1070 return r; 1071 } 1072 } 1073 /* MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(CONST<i>(c)) */ 1074 if (true 1075 // check expression type 1076 && expArg instanceof harpoon.IR.Tree.MEM 1077 // check operand types 1078 && ( 1079 expArg.type() == Type.DOUBLE || 1080 expArg.type() == Type.FLOAT || 1081 expArg.type() == Type.LONG || 1082 expArg.type() == Type.POINTER || 1083 ( expArg.type() == Type.INT && ! 1084 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1085 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1086 (((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall() && ( 1087 ((harpoon.IR.Tree.PreciselyTyped)expArg).signed() ? ( 1088 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 1089 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 1090 false) : ( 1091 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 1092 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 1093 false) ) ) || 1094 false ) 1095 // end check operand types 1096 // check child 1097 // check expression type 1098 && ((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.CONST 1099 // check operand types 1100 && ( 1101 ( ((harpoon.IR.Tree.MEM)expArg).getExp().type() == Type.INT && ! 1102 (((harpoon.IR.Tree.MEM)expArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 1103 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)expArg).getExp()).isSmall())) || 1104 false ) 1105 // end check operand types 1106 ){ 1107 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.MEM)expArg).getExp()).value; 1108 harpoon.IR.Tree.MEM ROOT = (harpoon.IR.Tree.MEM) expArg; 1109 _matched_ = true; 1110 1111 if (_matched_) { // action code! degree: 2 1112 1113 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1114 clearDecl(); 1115 declare(r, code.getTreeDerivation(), ROOT); 1116 1117 String srcsuff = (ROOT.isDoubleWord()) ? "h" : ""; 1118 emit (ROOT, "ld"+loadSuffix(ROOT) + " ["+c+"], `d0"+srcsuff + "", 1119 new Temp[] { r }, null); 1120 return r; 1121 } 1122 } 1123 /* BINOP<l>(SHL,e1,e2) */ 1124 if (true 1125 // check expression type 1126 && expArg instanceof harpoon.IR.Tree.BINOP 1127 // check opcode 1128 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.SHL 1129 // check operand types 1130 && ( 1131 expArg.type() == Type.LONG || 1132 false ) 1133 // end check operand types 1134 // check left child 1135 // no check needed for ExpId children 1136 // check right child 1137 // no check needed for ExpId children 1138 ){ 1139 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1140 _matched_ = true; 1141 1142 if (_matched_) { // action code! degree: 1 1143 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1144 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1145 1146 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1147 clearDecl(); 1148 declare(r, code.getTreeDerivation(), ROOT); 1149 1150 declare(rego[0], HClass.Void); 1151 declare(rego[1], HClass.Void); 1152 declare(rego[2], HClass.Int); 1153 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1154 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[1] }, new Temp[] { e1 }); 1155 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[2] }, new Temp[] { e2 }); 1156 emit (ROOT, "call __ashldi3", 1157 new Temp[] { rego[0], rego[1] }, new Temp[] { rego[0], rego[1], rego[2] }); 1158 emitDELAYSLOT (ROOT); 1159 emit (ROOT, "mov `s0, `d0h", new Temp[] { r }, new Temp[] { rego[0] }); 1160 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { rego[1] }); 1161 1162 return r; 1163 } 1164 } 1165 /* BINOP<l>(SHR,e1,e2) */ 1166 if (true 1167 // check expression type 1168 && expArg instanceof harpoon.IR.Tree.BINOP 1169 // check opcode 1170 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.SHR 1171 // check operand types 1172 && ( 1173 expArg.type() == Type.LONG || 1174 false ) 1175 // end check operand types 1176 // check left child 1177 // no check needed for ExpId children 1178 // check right child 1179 // no check needed for ExpId children 1180 ){ 1181 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1182 _matched_ = true; 1183 1184 if (_matched_) { // action code! degree: 1 1185 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1186 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1187 1188 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1189 clearDecl(); 1190 declare(r, code.getTreeDerivation(), ROOT); 1191 1192 declare(rego[0], HClass.Void); 1193 declare(rego[1], HClass.Void); 1194 declare(rego[2], HClass.Int); 1195 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1196 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[1] }, new Temp[] { e1 }); 1197 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[2] }, new Temp[] { e2 }); 1198 emit (ROOT, "call __ashrdi3", 1199 new Temp[] { rego[0], rego[1] }, new Temp[] { rego[0], rego[1], rego[2] }); 1200 emitDELAYSLOT (ROOT); 1201 emit (ROOT, "mov `s0, `d0h", new Temp[] { r }, new Temp[] { rego[0] }); 1202 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { rego[1] }); 1203 1204 return r; 1205 } 1206 } 1207 /* BINOP<l>(USHR,e1,e2) */ 1208 if (true 1209 // check expression type 1210 && expArg instanceof harpoon.IR.Tree.BINOP 1211 // check opcode 1212 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.USHR 1213 // check operand types 1214 && ( 1215 expArg.type() == Type.LONG || 1216 false ) 1217 // end check operand types 1218 // check left child 1219 // no check needed for ExpId children 1220 // check right child 1221 // no check needed for ExpId children 1222 ){ 1223 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1224 _matched_ = true; 1225 1226 if (_matched_) { // action code! degree: 1 1227 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1228 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1229 1230 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1231 clearDecl(); 1232 declare(r, code.getTreeDerivation(), ROOT); 1233 1234 declare(rego[0], HClass.Void); 1235 declare(rego[1], HClass.Void); 1236 declare(rego[2], HClass.Int); 1237 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1238 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[1] }, new Temp[] { e1 }); 1239 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[2] }, new Temp[] { e2 }); 1240 emit (ROOT, "call __lshrdi3", 1241 new Temp[] { rego[0], rego[1] }, new Temp[] { rego[0], rego[1], rego[2] }); 1242 emitDELAYSLOT (ROOT); 1243 emit (ROOT, "mov `s0, `d0h", new Temp[] { r }, new Temp[] { rego[0] }); 1244 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { rego[1] }); 1245 1246 return r; 1247 } 1248 } 1249 /* BINOP<i,p>(op,e1,e2) */ 1250 if (true 1251 // check expression type 1252 && expArg instanceof harpoon.IR.Tree.BINOP 1253 // check operand types 1254 && ( 1255 expArg.type() == Type.POINTER || 1256 ( expArg.type() == Type.INT && ! 1257 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1258 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1259 false ) 1260 // end check operand types 1261 // check left child 1262 // no check needed for ExpId children 1263 // check right child 1264 // no check needed for ExpId children 1265 ){ 1266 int op = ((harpoon.IR.Tree.BINOP) expArg).op; 1267 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1268 _matched_ = true&& ( isShift(op) || isCommutative(op) ); 1269 1270 if (_matched_) { // action code! degree: 1 1271 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1272 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1273 1274 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1275 clearDecl(); 1276 declare(r, code.getTreeDerivation(), ROOT); 1277 1278 emit (ROOT, bop(op)+" `s0, `s1, `d0", 1279 new Temp[] { r }, new Temp[] { e1, e2 }); 1280 return r; 1281 } 1282 } 1283 /* BINOP<l>(AND,e1,e2) */ 1284 if (true 1285 // check expression type 1286 && expArg instanceof harpoon.IR.Tree.BINOP 1287 // check opcode 1288 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.AND 1289 // check operand types 1290 && ( 1291 expArg.type() == Type.LONG || 1292 false ) 1293 // end check operand types 1294 // check left child 1295 // no check needed for ExpId children 1296 // check right child 1297 // no check needed for ExpId children 1298 ){ 1299 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1300 _matched_ = true; 1301 1302 if (_matched_) { // action code! degree: 1 1303 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1304 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1305 1306 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1307 clearDecl(); 1308 declare(r, code.getTreeDerivation(), ROOT); 1309 1310 emit (ROOT, "and `s0l, `s1l, `d0l", 1311 new Temp[] { r }, new Temp[] { e1, e2 }); 1312 emit (ROOT, "and `s0h, `s1h, `d0h", 1313 new Temp[] { r }, new Temp[] { e1, e2 }); 1314 return r; 1315 } 1316 } 1317 /* BINOP<l>(XOR,e1,e2) */ 1318 if (true 1319 // check expression type 1320 && expArg instanceof harpoon.IR.Tree.BINOP 1321 // check opcode 1322 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.XOR 1323 // check operand types 1324 && ( 1325 expArg.type() == Type.LONG || 1326 false ) 1327 // end check operand types 1328 // check left child 1329 // no check needed for ExpId children 1330 // check right child 1331 // no check needed for ExpId children 1332 ){ 1333 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1334 _matched_ = true; 1335 1336 if (_matched_) { // action code! degree: 1 1337 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1338 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1339 1340 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1341 clearDecl(); 1342 declare(r, code.getTreeDerivation(), ROOT); 1343 1344 emit (ROOT, "xor `s0l, `s1l, `d0l", 1345 new Temp[] { r }, new Temp[] { e1, e2 }); 1346 emit (ROOT, "xor `s0h, `s1h, `d0h", 1347 new Temp[] { r }, new Temp[] { e1, e2 }); 1348 return r; 1349 } 1350 } 1351 /* BINOP<l>(OR,e1,e2) */ 1352 if (true 1353 // check expression type 1354 && expArg instanceof harpoon.IR.Tree.BINOP 1355 // check opcode 1356 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.OR 1357 // check operand types 1358 && ( 1359 expArg.type() == Type.LONG || 1360 false ) 1361 // end check operand types 1362 // check left child 1363 // no check needed for ExpId children 1364 // check right child 1365 // no check needed for ExpId children 1366 ){ 1367 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1368 _matched_ = true; 1369 1370 if (_matched_) { // action code! degree: 1 1371 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1372 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1373 1374 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1375 clearDecl(); 1376 declare(r, code.getTreeDerivation(), ROOT); 1377 1378 emit (ROOT, "or `s0l, `s1l, `d0l", 1379 new Temp[] { r }, new Temp[] { e1, e2 }); 1380 emit (ROOT, "or `s0h, `s1h, `d0h", 1381 new Temp[] { r }, new Temp[] { e1, e2 }); 1382 return r; 1383 } 1384 } 1385 /* BINOP<l>(ADD,e1,e2) */ 1386 if (true 1387 // check expression type 1388 && expArg instanceof harpoon.IR.Tree.BINOP 1389 // check opcode 1390 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.ADD 1391 // check operand types 1392 && ( 1393 expArg.type() == Type.LONG || 1394 false ) 1395 // end check operand types 1396 // check left child 1397 // no check needed for ExpId children 1398 // check right child 1399 // no check needed for ExpId children 1400 ){ 1401 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1402 _matched_ = true; 1403 1404 if (_matched_) { // action code! degree: 1 1405 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1406 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1407 1408 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1409 clearDecl(); 1410 declare(r, code.getTreeDerivation(), ROOT); 1411 1412 emitCC (ROOT, "addcc `s0l, `s1l, `d0l", 1413 new Temp[] { r }, new Temp[] { e1, e2 }); 1414 emitCC (ROOT, "addx `s0h, `s1h, `d0h", 1415 new Temp[] { r }, new Temp[] { e1, e2 }); 1416 return r; 1417 } 1418 } 1419 /* BINOP<f,d>(ADD,e1,e2) */ 1420 if (true 1421 // check expression type 1422 && expArg instanceof harpoon.IR.Tree.BINOP 1423 // check opcode 1424 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.ADD 1425 // check operand types 1426 && ( 1427 expArg.type() == Type.DOUBLE || 1428 expArg.type() == Type.FLOAT || 1429 false ) 1430 // end check operand types 1431 // check left child 1432 // no check needed for ExpId children 1433 // check right child 1434 // no check needed for ExpId children 1435 ){ 1436 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1437 _matched_ = true; 1438 1439 if (_matched_) { // action code! degree: 1 1440 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1441 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1442 1443 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1444 clearDecl(); 1445 declare(r, code.getTreeDerivation(), ROOT); 1446 1447 String s = (ROOT.isDoubleWord()) ? "d" : "s"; 1448 emit (ROOT, "fadd"+s+" `s0, `s1, `d0", 1449 new Temp[] { r }, new Temp[] { e1, e2 }); 1450 return r; 1451 } 1452 } 1453 /* BINOP<l>(MUL,e1,e2) */ 1454 if (true 1455 // check expression type 1456 && expArg instanceof harpoon.IR.Tree.BINOP 1457 // check opcode 1458 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.MUL 1459 // check operand types 1460 && ( 1461 expArg.type() == Type.LONG || 1462 false ) 1463 // end check operand types 1464 // check left child 1465 // no check needed for ExpId children 1466 // check right child 1467 // no check needed for ExpId children 1468 ){ 1469 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1470 _matched_ = true; 1471 1472 if (_matched_) { // action code! degree: 1 1473 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1474 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1475 1476 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1477 clearDecl(); 1478 declare(r, code.getTreeDerivation(), ROOT); 1479 1480 declare(rego[0], HClass.Void); 1481 declare(rego[1], HClass.Void); 1482 declare(rego[2], HClass.Void); 1483 declare(rego[3], HClass.Void); 1484 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1485 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[1] }, new Temp[] { e1 }); 1486 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[2] }, new Temp[] { e2 }); 1487 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[3] }, new Temp[] { e2 }); 1488 emit (ROOT, "call __muldi3", 1489 new Temp[] { rego[0], rego[1] }, new Temp[] { rego[0], rego[1], rego[2], rego[3] }); 1490 emitDELAYSLOT (ROOT); 1491 emit (ROOT, "mov `s0, `d0h", new Temp[] { r }, new Temp[] { rego[0] }); 1492 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { rego[1] }); 1493 return r; 1494 } 1495 } 1496 /* BINOP<i,p>(MUL,e1,e2) */ 1497 if (true 1498 // check expression type 1499 && expArg instanceof harpoon.IR.Tree.BINOP 1500 // check opcode 1501 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.MUL 1502 // check operand types 1503 && ( 1504 expArg.type() == Type.POINTER || 1505 ( expArg.type() == Type.INT && ! 1506 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1507 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1508 false ) 1509 // end check operand types 1510 // check left child 1511 // no check needed for ExpId children 1512 // check right child 1513 // no check needed for ExpId children 1514 ){ 1515 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1516 _matched_ = true; 1517 1518 if (_matched_) { // action code! degree: 1 1519 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1520 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1521 1522 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1523 clearDecl(); 1524 declare(r, code.getTreeDerivation(), ROOT); 1525 1526 declare(rego[0], HClass.Int); 1527 declare(rego[1], HClass.Int); 1528 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1529 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[1] }, new Temp[] { e2 }); 1530 emit (ROOT, "call .mul", new Temp[] { rego[0] }, new Temp[] { rego[0], rego[1] }); 1531 emitDELAYSLOT (ROOT); 1532 emit (ROOT, "mov `s0, `d0", new Temp[] { r }, new Temp[] { rego[0] }); 1533 return r; 1534 } 1535 } 1536 /* BINOP<f,d>(MUL,e1,e2) */ 1537 if (true 1538 // check expression type 1539 && expArg instanceof harpoon.IR.Tree.BINOP 1540 // check opcode 1541 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.MUL 1542 // check operand types 1543 && ( 1544 expArg.type() == Type.DOUBLE || 1545 expArg.type() == Type.FLOAT || 1546 false ) 1547 // end check operand types 1548 // check left child 1549 // no check needed for ExpId children 1550 // check right child 1551 // no check needed for ExpId children 1552 ){ 1553 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1554 _matched_ = true; 1555 1556 if (_matched_) { // action code! degree: 1 1557 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1558 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1559 1560 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1561 clearDecl(); 1562 declare(r, code.getTreeDerivation(), ROOT); 1563 1564 String s = (ROOT.isDoubleWord()) ? "d" : "s"; 1565 emit (ROOT, "fmul"+s+" `s0, `s1, `d0", 1566 new Temp[] { r }, new Temp[] { e1, e2 }); 1567 return r; 1568 } 1569 } 1570 /* BINOP<l>(DIV,e1,e2) */ 1571 if (true 1572 // check expression type 1573 && expArg instanceof harpoon.IR.Tree.BINOP 1574 // check opcode 1575 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.DIV 1576 // check operand types 1577 && ( 1578 expArg.type() == Type.LONG || 1579 false ) 1580 // end check operand types 1581 // check left child 1582 // no check needed for ExpId children 1583 // check right child 1584 // no check needed for ExpId children 1585 ){ 1586 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1587 _matched_ = true; 1588 1589 if (_matched_) { // action code! degree: 1 1590 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1591 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1592 1593 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1594 clearDecl(); 1595 declare(r, code.getTreeDerivation(), ROOT); 1596 1597 declare(rego[0], HClass.Void); 1598 declare(rego[1], HClass.Void); 1599 declare(rego[2], HClass.Void); 1600 declare(rego[3], HClass.Void); 1601 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1602 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[1] }, new Temp[] { e1 }); 1603 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[2] }, new Temp[] { e2 }); 1604 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[3] }, new Temp[] { e2 }); 1605 emit (ROOT, "call __divdi3", 1606 new Temp[] { rego[0], rego[1] }, new Temp[] { rego[0], rego[1], rego[2], rego[3] }); 1607 emitDELAYSLOT (ROOT); 1608 emit (ROOT, "mov `s0, `d0h", new Temp[] { r }, new Temp[] { rego[0] }); 1609 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { rego[1] }); 1610 return r; 1611 } 1612 } 1613 /* BINOP<i,p>(DIV,e1,e2) */ 1614 if (true 1615 // check expression type 1616 && expArg instanceof harpoon.IR.Tree.BINOP 1617 // check opcode 1618 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.DIV 1619 // check operand types 1620 && ( 1621 expArg.type() == Type.POINTER || 1622 ( expArg.type() == Type.INT && ! 1623 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1624 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1625 false ) 1626 // end check operand types 1627 // check left child 1628 // no check needed for ExpId children 1629 // check right child 1630 // no check needed for ExpId children 1631 ){ 1632 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1633 _matched_ = true; 1634 1635 if (_matched_) { // action code! degree: 1 1636 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1637 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1638 1639 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1640 clearDecl(); 1641 declare(r, code.getTreeDerivation(), ROOT); 1642 1643 declare(rego[0], HClass.Int); 1644 declare(rego[1], HClass.Int); 1645 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1646 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[1] }, new Temp[] { e2 }); 1647 emit (ROOT, "call .div", new Temp[] { rego[0]}, new Temp[] { rego[0], rego[1] }); 1648 emitDELAYSLOT (ROOT); 1649 emit (ROOT, "mov `s0, `d0", new Temp[] { r }, new Temp[] { rego[0] }); 1650 return r; 1651 } 1652 } 1653 /* BINOP<f,d>(DIV,e1,e2) */ 1654 if (true 1655 // check expression type 1656 && expArg instanceof harpoon.IR.Tree.BINOP 1657 // check opcode 1658 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.DIV 1659 // check operand types 1660 && ( 1661 expArg.type() == Type.DOUBLE || 1662 expArg.type() == Type.FLOAT || 1663 false ) 1664 // end check operand types 1665 // check left child 1666 // no check needed for ExpId children 1667 // check right child 1668 // no check needed for ExpId children 1669 ){ 1670 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1671 _matched_ = true; 1672 1673 if (_matched_) { // action code! degree: 1 1674 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1675 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1676 1677 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1678 clearDecl(); 1679 declare(r, code.getTreeDerivation(), ROOT); 1680 1681 String s = (ROOT.isDoubleWord()) ? "d" : "s"; 1682 emit (ROOT, "fdiv"+s+" `s0, `s1, `d0", 1683 new Temp[] { r }, new Temp[] { e1, e2 }); 1684 return r; 1685 } 1686 } 1687 /* BINOP<l>(REM,e1,e2) */ 1688 if (true 1689 // check expression type 1690 && expArg instanceof harpoon.IR.Tree.BINOP 1691 // check opcode 1692 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.REM 1693 // check operand types 1694 && ( 1695 expArg.type() == Type.LONG || 1696 false ) 1697 // end check operand types 1698 // check left child 1699 // no check needed for ExpId children 1700 // check right child 1701 // no check needed for ExpId children 1702 ){ 1703 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1704 _matched_ = true; 1705 1706 if (_matched_) { // action code! degree: 1 1707 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1708 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1709 1710 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1711 clearDecl(); 1712 declare(r, code.getTreeDerivation(), ROOT); 1713 1714 declare(rego[0], HClass.Void); 1715 declare(rego[1], HClass.Void); 1716 declare(rego[2], HClass.Void); 1717 declare(rego[3], HClass.Void); 1718 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1719 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[1] }, new Temp[] { e1 }); 1720 emit (ROOT, "mov `s0h, `d0", new Temp[] { rego[2] }, new Temp[] { e2 }); 1721 emit (ROOT, "mov `s0l, `d0", new Temp[] { rego[3] }, new Temp[] { e2 }); 1722 emit (ROOT, "call __moddi3", 1723 new Temp[] { rego[0], rego[1] }, new Temp[] { rego[0], rego[1], rego[2], rego[3] }); 1724 emitDELAYSLOT (ROOT); 1725 emit (ROOT, "mov `s0, `d0h", new Temp[] { r }, new Temp[] { rego[0] }); 1726 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { rego[1] }); 1727 return r; 1728 } 1729 } 1730 /* BINOP<i,p>(REM,e1,e2) */ 1731 if (true 1732 // check expression type 1733 && expArg instanceof harpoon.IR.Tree.BINOP 1734 // check opcode 1735 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.REM 1736 // check operand types 1737 && ( 1738 expArg.type() == Type.POINTER || 1739 ( expArg.type() == Type.INT && ! 1740 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1741 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1742 false ) 1743 // end check operand types 1744 // check left child 1745 // no check needed for ExpId children 1746 // check right child 1747 // no check needed for ExpId children 1748 ){ 1749 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1750 _matched_ = true; 1751 1752 if (_matched_) { // action code! degree: 1 1753 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1754 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1755 1756 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1757 clearDecl(); 1758 declare(r, code.getTreeDerivation(), ROOT); 1759 1760 declare(rego[0], HClass.Int); 1761 declare(rego[1], HClass.Int); 1762 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[0] }, new Temp[] { e1 }); 1763 emit (ROOT, "mov `s0, `d0", new Temp[] { rego[1] }, new Temp[] { e2 }); 1764 emit (ROOT, "call .rem", new Temp[] { rego[0] }, new Temp[] { rego[0], rego[1] }); 1765 emitDELAYSLOT (ROOT); 1766 emit (ROOT, "mov `s0, `d0", new Temp[] { r }, new Temp[] { rego[0] }); 1767 return r; 1768 } 1769 } 1770 /* BINOP<i,l,f,d,p>(CMPLT,e1,e2) */ 1771 if (true 1772 // check expression type 1773 && expArg instanceof harpoon.IR.Tree.BINOP 1774 // check opcode 1775 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPLT 1776 // check operand types 1777 && ( 1778 expArg.type() == Type.DOUBLE || 1779 expArg.type() == Type.FLOAT || 1780 expArg.type() == Type.LONG || 1781 expArg.type() == Type.POINTER || 1782 ( expArg.type() == Type.INT && ! 1783 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1784 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1785 false ) 1786 // end check operand types 1787 // check left child 1788 // no check needed for ExpId children 1789 // check right child 1790 // no check needed for ExpId children 1791 ){ 1792 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1793 _matched_ = true&& ( ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 1794 1795 if (_matched_) { // action code! degree: 1 1796 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1797 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1798 1799 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1800 clearDecl(); 1801 declare(r, code.getTreeDerivation(), ROOT); 1802 1803 Label templabel = new Label(); 1804 emit (ROOT, "mov 0, `d0", new Temp[] { r }, new Temp[] {}); 1805 emitCC (ROOT, "cmp `s0, `s1", new Temp[] {}, new Temp[] { e1, e2 }); 1806 emitCC (ROOT, "bge "+templabel+"", 1807 new Temp[] {}, new Temp[] {}, new Label[] { templabel }); 1808 emitDELAYSLOT (ROOT); 1809 emit (ROOT, "mov 1, `d0", new Temp[] { r } , new Temp[] {}); 1810 emitLABEL(ROOT, templabel + ":", templabel); 1811 return r; 1812 } 1813 } 1814 /* BINOP<i,l,f,d,p>(CMPLE,e1,e2) */ 1815 if (true 1816 // check expression type 1817 && expArg instanceof harpoon.IR.Tree.BINOP 1818 // check opcode 1819 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPLE 1820 // check operand types 1821 && ( 1822 expArg.type() == Type.DOUBLE || 1823 expArg.type() == Type.FLOAT || 1824 expArg.type() == Type.LONG || 1825 expArg.type() == Type.POINTER || 1826 ( expArg.type() == Type.INT && ! 1827 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1828 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1829 false ) 1830 // end check operand types 1831 // check left child 1832 // no check needed for ExpId children 1833 // check right child 1834 // no check needed for ExpId children 1835 ){ 1836 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1837 _matched_ = true&& ( ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 1838 1839 if (_matched_) { // action code! degree: 1 1840 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1841 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1842 1843 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1844 clearDecl(); 1845 declare(r, code.getTreeDerivation(), ROOT); 1846 1847 Label templabel = new Label(); 1848 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 1849 emitCC (ROOT, "cmp `s0, `s1", new Temp[] {}, new Temp[] { e1, e2 }); 1850 emitCC (ROOT, "bg "+templabel+"", 1851 new Temp[] {}, new Temp[] {}, new Label[] { templabel }); 1852 emitDELAYSLOT (ROOT); 1853 emit (ROOT, "mov 1, `d0", new Temp[] { r } , new Temp[] {}); 1854 emitLABEL(ROOT, templabel + ":", templabel); 1855 return r; 1856 } 1857 } 1858 /* BINOP<i,l,f,d,p>(CMPEQ,e1,e2) */ 1859 if (true 1860 // check expression type 1861 && expArg instanceof harpoon.IR.Tree.BINOP 1862 // check opcode 1863 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPEQ 1864 // check operand types 1865 && ( 1866 expArg.type() == Type.DOUBLE || 1867 expArg.type() == Type.FLOAT || 1868 expArg.type() == Type.LONG || 1869 expArg.type() == Type.POINTER || 1870 ( expArg.type() == Type.INT && ! 1871 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1872 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1873 false ) 1874 // end check operand types 1875 // check left child 1876 // no check needed for ExpId children 1877 // check right child 1878 // no check needed for ExpId children 1879 ){ 1880 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1881 _matched_ = true&& ( ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 1882 1883 if (_matched_) { // action code! degree: 1 1884 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1885 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1886 1887 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1888 clearDecl(); 1889 declare(r, code.getTreeDerivation(), ROOT); 1890 1891 Label templabel = new Label(); 1892 emit (ROOT, "mov 0, `d0", new Temp[] { r }, new Temp[] {}); 1893 emitCC (ROOT, "cmp `s0, `s1", new Temp[] {}, new Temp[] { e1, e2 }); 1894 emitCC (ROOT, "bne "+templabel+"", 1895 new Temp[] {}, new Temp[] {}, new Label[] { templabel }); 1896 emitDELAYSLOT (ROOT); 1897 emit (ROOT, "mov 1, `d0", new Temp[] { r } , new Temp[] {}); 1898 emitLABEL(ROOT, templabel + ":", templabel); 1899 return r; 1900 } 1901 } 1902 /* BINOP<i,l,f,d,p>(CMPGE,e1,e2) */ 1903 if (true 1904 // check expression type 1905 && expArg instanceof harpoon.IR.Tree.BINOP 1906 // check opcode 1907 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPGE 1908 // check operand types 1909 && ( 1910 expArg.type() == Type.DOUBLE || 1911 expArg.type() == Type.FLOAT || 1912 expArg.type() == Type.LONG || 1913 expArg.type() == Type.POINTER || 1914 ( expArg.type() == Type.INT && ! 1915 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1916 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1917 false ) 1918 // end check operand types 1919 // check left child 1920 // no check needed for ExpId children 1921 // check right child 1922 // no check needed for ExpId children 1923 ){ 1924 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1925 _matched_ = true&& ( ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 1926 1927 if (_matched_) { // action code! degree: 1 1928 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1929 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1930 1931 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1932 clearDecl(); 1933 declare(r, code.getTreeDerivation(), ROOT); 1934 1935 Label templabel = new Label(); 1936 emit (ROOT, "mov 0, `d0", new Temp[] { r }, new Temp[] {}); 1937 emitCC (ROOT, "cmp `s0, `s1", new Temp[] {}, new Temp[] { e1, e2 }); 1938 emitCC (ROOT, "bl "+templabel+"", 1939 new Temp[] {}, new Temp[] {}, new Label[] { templabel }); 1940 emitDELAYSLOT (ROOT); 1941 emit (ROOT, "mov 1, `d0", new Temp[] { r } , new Temp[] {}); 1942 emitLABEL(ROOT, templabel + ":", templabel); 1943 return r; 1944 } 1945 } 1946 /* BINOP<i,l,f,d,p>(CMPGT,e1,e2) */ 1947 if (true 1948 // check expression type 1949 && expArg instanceof harpoon.IR.Tree.BINOP 1950 // check opcode 1951 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPGT 1952 // check operand types 1953 && ( 1954 expArg.type() == Type.DOUBLE || 1955 expArg.type() == Type.FLOAT || 1956 expArg.type() == Type.LONG || 1957 expArg.type() == Type.POINTER || 1958 ( expArg.type() == Type.INT && ! 1959 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 1960 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 1961 false ) 1962 // end check operand types 1963 // check left child 1964 // no check needed for ExpId children 1965 // check right child 1966 // no check needed for ExpId children 1967 ){ 1968 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 1969 _matched_ = true&& ( ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 1970 1971 if (_matched_) { // action code! degree: 1 1972 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 1973 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 1974 1975 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 1976 clearDecl(); 1977 declare(r, code.getTreeDerivation(), ROOT); 1978 1979 Label templabel = new Label(); 1980 emit (ROOT, "mov 0, `d0", new Temp[] { r }, new Temp[] {}); 1981 emitCC (ROOT, "cmp `s0, `s1", new Temp[] {}, new Temp[] { e1, e2 }); 1982 emitCC (ROOT, "ble "+templabel+"", 1983 new Temp[] {}, new Temp[] {}, new Label[] { templabel }); 1984 emitDELAYSLOT (ROOT); 1985 emit (ROOT, "mov 1, `d0", new Temp[] { r } , new Temp[] {}); 1986 emitLABEL(ROOT, templabel + ":", templabel); 1987 return r; 1988 } 1989 } 1990 /* BINOP<i,l,f,d,p>(CMPLT,e1,e2) */ 1991 if (true 1992 // check expression type 1993 && expArg instanceof harpoon.IR.Tree.BINOP 1994 // check opcode 1995 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPLT 1996 // check operand types 1997 && ( 1998 expArg.type() == Type.DOUBLE || 1999 expArg.type() == Type.FLOAT || 2000 expArg.type() == Type.LONG || 2001 expArg.type() == Type.POINTER || 2002 ( expArg.type() == Type.INT && ! 2003 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2004 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2005 false ) 2006 // end check operand types 2007 // check left child 2008 // no check needed for ExpId children 2009 // check right child 2010 // no check needed for ExpId children 2011 ){ 2012 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2013 _matched_ = true&& ( ROOT.operandType() == Type.LONG ); 2014 2015 if (_matched_) { // action code! degree: 1 2016 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2017 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2018 2019 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2020 clearDecl(); 2021 declare(r, code.getTreeDerivation(), ROOT); 2022 2023 Label templabel = new Label(); 2024 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2025 emitCC (ROOT, "cmp `s0h, `s1h", null, new Temp[] { e1, e2}); 2026 emitCC (ROOT, "bge "+templabel+"", null, null, new Label[] { templabel }); 2027 emitDELAYSLOT (ROOT); 2028 emitCC (ROOT, "cmp `s0l, `s1l", null, new Temp[] { e1, e2 }); 2029 emitCC (ROOT, "bge "+templabel+"", null, null, new Label[] { templabel }); 2030 emitDELAYSLOT (ROOT); 2031 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2032 emitLABEL (ROOT, templabel + ":", templabel); 2033 return r; 2034 } 2035 } 2036 /* BINOP<i,l,f,d,p>(CMPLE,e1,e2) */ 2037 if (true 2038 // check expression type 2039 && expArg instanceof harpoon.IR.Tree.BINOP 2040 // check opcode 2041 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPLE 2042 // check operand types 2043 && ( 2044 expArg.type() == Type.DOUBLE || 2045 expArg.type() == Type.FLOAT || 2046 expArg.type() == Type.LONG || 2047 expArg.type() == Type.POINTER || 2048 ( expArg.type() == Type.INT && ! 2049 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2050 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2051 false ) 2052 // end check operand types 2053 // check left child 2054 // no check needed for ExpId children 2055 // check right child 2056 // no check needed for ExpId children 2057 ){ 2058 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2059 _matched_ = true&& ( ROOT.operandType() == Type.LONG ); 2060 2061 if (_matched_) { // action code! degree: 1 2062 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2063 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2064 2065 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2066 clearDecl(); 2067 declare(r, code.getTreeDerivation(), ROOT); 2068 2069 Label templabel = new Label(); 2070 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2071 emitCC (ROOT, "cmp `s0h, `s1h", null, new Temp[] { e1, e2 }); 2072 emitCC (ROOT, "bg "+templabel+"", null, null, new Label[] { templabel }); 2073 emitDELAYSLOT (ROOT); 2074 emitCC (ROOT, "cmp `s0l, `s1l", null, new Temp[] { e1, e2 }); 2075 emitCC (ROOT, "bg "+templabel+"", null, null, new Label[] { templabel }); 2076 emitDELAYSLOT (ROOT); 2077 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2078 emitLABEL (ROOT, templabel + ":", templabel); 2079 return r; 2080 } 2081 } 2082 /* BINOP<i,l,f,d,p>(CMPEQ,e1,e2) */ 2083 if (true 2084 // check expression type 2085 && expArg instanceof harpoon.IR.Tree.BINOP 2086 // check opcode 2087 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPEQ 2088 // check operand types 2089 && ( 2090 expArg.type() == Type.DOUBLE || 2091 expArg.type() == Type.FLOAT || 2092 expArg.type() == Type.LONG || 2093 expArg.type() == Type.POINTER || 2094 ( expArg.type() == Type.INT && ! 2095 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2096 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2097 false ) 2098 // end check operand types 2099 // check left child 2100 // no check needed for ExpId children 2101 // check right child 2102 // no check needed for ExpId children 2103 ){ 2104 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2105 _matched_ = true&& ( ROOT.operandType() == Type.LONG ); 2106 2107 if (_matched_) { // action code! degree: 1 2108 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2109 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2110 2111 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2112 clearDecl(); 2113 declare(r, code.getTreeDerivation(), ROOT); 2114 2115 Label templabel = new Label(); 2116 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2117 emitCC (ROOT, "cmp `s0h, `s1h", null, new Temp[] { e1, e2 }); 2118 emitCC (ROOT, "bne "+templabel+"", null, null, new Label[] { templabel }); 2119 emitDELAYSLOT (ROOT); 2120 emitCC (ROOT, "cmp `s0l, `s1l", null, new Temp[] { e1, e2 }); 2121 emitCC (ROOT, "bne "+templabel+"", null, null, new Label[] { templabel }); 2122 emitDELAYSLOT (ROOT); 2123 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2124 emitLABEL (ROOT, templabel + ":", templabel); 2125 return r; 2126 } 2127 } 2128 /* BINOP<i,l,f,d,p>(CMPGE,e1,e2) */ 2129 if (true 2130 // check expression type 2131 && expArg instanceof harpoon.IR.Tree.BINOP 2132 // check opcode 2133 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPGE 2134 // check operand types 2135 && ( 2136 expArg.type() == Type.DOUBLE || 2137 expArg.type() == Type.FLOAT || 2138 expArg.type() == Type.LONG || 2139 expArg.type() == Type.POINTER || 2140 ( expArg.type() == Type.INT && ! 2141 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2142 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2143 false ) 2144 // end check operand types 2145 // check left child 2146 // no check needed for ExpId children 2147 // check right child 2148 // no check needed for ExpId children 2149 ){ 2150 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2151 _matched_ = true&& ( ROOT.operandType() == Type.LONG ); 2152 2153 if (_matched_) { // action code! degree: 1 2154 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2155 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2156 2157 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2158 clearDecl(); 2159 declare(r, code.getTreeDerivation(), ROOT); 2160 2161 Label templabel = new Label(); 2162 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2163 emitCC (ROOT, "cmp `s0h, `s1h", null, new Temp[] { e1, e2 }); 2164 emitCC (ROOT, "bl "+templabel+"", null, null, new Label[] { templabel }); 2165 emitDELAYSLOT (ROOT); 2166 emitCC (ROOT, "cmp `s0l, `s1l", null, new Temp[] { e1, e2 }); 2167 emitCC (ROOT, "bl "+templabel+"", null, null, new Label[] { templabel }); 2168 emitDELAYSLOT (ROOT); 2169 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2170 emitLABEL (ROOT, templabel + ":", templabel); 2171 return r; 2172 } 2173 } 2174 /* BINOP<i,l,f,d,p>(CMPGT,e1,e2) */ 2175 if (true 2176 // check expression type 2177 && expArg instanceof harpoon.IR.Tree.BINOP 2178 // check opcode 2179 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPGT 2180 // check operand types 2181 && ( 2182 expArg.type() == Type.DOUBLE || 2183 expArg.type() == Type.FLOAT || 2184 expArg.type() == Type.LONG || 2185 expArg.type() == Type.POINTER || 2186 ( expArg.type() == Type.INT && ! 2187 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2188 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2189 false ) 2190 // end check operand types 2191 // check left child 2192 // no check needed for ExpId children 2193 // check right child 2194 // no check needed for ExpId children 2195 ){ 2196 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2197 _matched_ = true&& ( ROOT.operandType() == Type.LONG ); 2198 2199 if (_matched_) { // action code! degree: 1 2200 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2201 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2202 2203 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2204 clearDecl(); 2205 declare(r, code.getTreeDerivation(), ROOT); 2206 2207 Label templabel = new Label(); 2208 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2209 emitCC (ROOT, "cmp `s0h, `s1h", null, new Temp[] { e1, e2 }); 2210 emitCC (ROOT, "ble "+templabel+"", null, null, new Label[] { templabel }); 2211 emitDELAYSLOT (ROOT); 2212 emitCC (ROOT, "cmp `s0l, `s1l", null, new Temp[] { e1, e2 }); 2213 emitCC (ROOT, "ble "+templabel+"", null, null, new Label[] { templabel }); 2214 emitDELAYSLOT (ROOT); 2215 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2216 emitLABEL (ROOT, templabel + ":", templabel); 2217 return r; 2218 } 2219 } 2220 /* BINOP<i,l,f,d,p>(CMPLT,e1,e2) */ 2221 if (true 2222 // check expression type 2223 && expArg instanceof harpoon.IR.Tree.BINOP 2224 // check opcode 2225 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPLT 2226 // check operand types 2227 && ( 2228 expArg.type() == Type.DOUBLE || 2229 expArg.type() == Type.FLOAT || 2230 expArg.type() == Type.LONG || 2231 expArg.type() == Type.POINTER || 2232 ( expArg.type() == Type.INT && ! 2233 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2234 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2235 false ) 2236 // end check operand types 2237 // check left child 2238 // no check needed for ExpId children 2239 // check right child 2240 // no check needed for ExpId children 2241 ){ 2242 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2243 _matched_ = true&& ( ROOT.operandType() == Type.FLOAT ); 2244 2245 if (_matched_) { // action code! degree: 1 2246 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2247 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2248 2249 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2250 clearDecl(); 2251 declare(r, code.getTreeDerivation(), ROOT); 2252 2253 Label templabel = new Label(); 2254 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2255 emitCC (ROOT, "fcmps `s0, `s1", null, new Temp[] { e1, e2 }); 2256 emitCC (ROOT, "nop", null, null); 2257 emitCC (ROOT, "fbge "+templabel+"", null, null, new Label[] {templabel}); 2258 emitDELAYSLOT (ROOT); 2259 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2260 emitLABEL (ROOT, templabel + ":", templabel); 2261 return r; 2262 } 2263 } 2264 /* BINOP<i,l,f,d,p>(CMPLE,e1,e2) */ 2265 if (true 2266 // check expression type 2267 && expArg instanceof harpoon.IR.Tree.BINOP 2268 // check opcode 2269 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPLE 2270 // check operand types 2271 && ( 2272 expArg.type() == Type.DOUBLE || 2273 expArg.type() == Type.FLOAT || 2274 expArg.type() == Type.LONG || 2275 expArg.type() == Type.POINTER || 2276 ( expArg.type() == Type.INT && ! 2277 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2278 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2279 false ) 2280 // end check operand types 2281 // check left child 2282 // no check needed for ExpId children 2283 // check right child 2284 // no check needed for ExpId children 2285 ){ 2286 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2287 _matched_ = true&& ( ROOT.operandType() == Type.FLOAT ); 2288 2289 if (_matched_) { // action code! degree: 1 2290 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2291 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2292 2293 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2294 clearDecl(); 2295 declare(r, code.getTreeDerivation(), ROOT); 2296 2297 Label templabel = new Label(); 2298 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2299 emitCC (ROOT, "fcmps `s0, `s1", null, new Temp[] { e1, e2 }); 2300 emitCC (ROOT, "nop", null, null); 2301 emitCC (ROOT, "fbg "+templabel+"", null, null, new Label[] {templabel}); 2302 emitDELAYSLOT (ROOT); 2303 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2304 emitLABEL (ROOT, templabel + ":", templabel); 2305 return r; 2306 } 2307 } 2308 /* BINOP<i,l,f,d,p>(CMPEQ,e1,e2) */ 2309 if (true 2310 // check expression type 2311 && expArg instanceof harpoon.IR.Tree.BINOP 2312 // check opcode 2313 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPEQ 2314 // check operand types 2315 && ( 2316 expArg.type() == Type.DOUBLE || 2317 expArg.type() == Type.FLOAT || 2318 expArg.type() == Type.LONG || 2319 expArg.type() == Type.POINTER || 2320 ( expArg.type() == Type.INT && ! 2321 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2322 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2323 false ) 2324 // end check operand types 2325 // check left child 2326 // no check needed for ExpId children 2327 // check right child 2328 // no check needed for ExpId children 2329 ){ 2330 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2331 _matched_ = true&& ( ROOT.operandType() == Type.FLOAT ); 2332 2333 if (_matched_) { // action code! degree: 1 2334 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2335 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2336 2337 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2338 clearDecl(); 2339 declare(r, code.getTreeDerivation(), ROOT); 2340 2341 Label templabel = new Label(); 2342 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2343 emitCC (ROOT, "fcmps `s0, `s1", null, new Temp[] { e1, e2 }); 2344 emitCC (ROOT, "nop", null, null); 2345 emitCC (ROOT, "fbne "+templabel+"", null, null, new Label[] {templabel}); 2346 emitDELAYSLOT (ROOT); 2347 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2348 emitLABEL (ROOT, templabel + ":", templabel); 2349 return r; 2350 } 2351 } 2352 /* BINOP<i,l,f,d,p>(CMPGE,e1,e2) */ 2353 if (true 2354 // check expression type 2355 && expArg instanceof harpoon.IR.Tree.BINOP 2356 // check opcode 2357 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPGE 2358 // check operand types 2359 && ( 2360 expArg.type() == Type.DOUBLE || 2361 expArg.type() == Type.FLOAT || 2362 expArg.type() == Type.LONG || 2363 expArg.type() == Type.POINTER || 2364 ( expArg.type() == Type.INT && ! 2365 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2366 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2367 false ) 2368 // end check operand types 2369 // check left child 2370 // no check needed for ExpId children 2371 // check right child 2372 // no check needed for ExpId children 2373 ){ 2374 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2375 _matched_ = true&& ( ROOT.operandType() == Type.FLOAT ); 2376 2377 if (_matched_) { // action code! degree: 1 2378 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2379 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2380 2381 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2382 clearDecl(); 2383 declare(r, code.getTreeDerivation(), ROOT); 2384 2385 Label templabel = new Label(); 2386 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2387 emitCC (ROOT, "fcmps `s0, `s1", null, new Temp[] { e1, e2 }); 2388 emitCC (ROOT, "nop", null, null); 2389 emitCC (ROOT, "fbl "+templabel+"", null, null, new Label[] { templabel }); 2390 emitDELAYSLOT (ROOT); 2391 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2392 emitLABEL (ROOT, templabel + ":", templabel); 2393 return r; 2394 } 2395 } 2396 /* BINOP<i,l,f,d,p>(CMPGT,e1,e2) */ 2397 if (true 2398 // check expression type 2399 && expArg instanceof harpoon.IR.Tree.BINOP 2400 // check opcode 2401 && ((harpoon.IR.Tree.BINOP)expArg).op == harpoon.IR.Tree.Bop.CMPGT 2402 // check operand types 2403 && ( 2404 expArg.type() == Type.DOUBLE || 2405 expArg.type() == Type.FLOAT || 2406 expArg.type() == Type.LONG || 2407 expArg.type() == Type.POINTER || 2408 ( expArg.type() == Type.INT && ! 2409 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2410 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2411 false ) 2412 // end check operand types 2413 // check left child 2414 // no check needed for ExpId children 2415 // check right child 2416 // no check needed for ExpId children 2417 ){ 2418 harpoon.IR.Tree.BINOP ROOT = (harpoon.IR.Tree.BINOP) expArg; 2419 _matched_ = true&& ( ROOT.operandType() == Type.FLOAT ); 2420 2421 if (_matched_) { // action code! degree: 1 2422 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getLeft()); 2423 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)expArg).getRight()); 2424 2425 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2426 clearDecl(); 2427 declare(r, code.getTreeDerivation(), ROOT); 2428 2429 Label templabel = new Label(); 2430 emit (ROOT, "mov 0, `d0", new Temp[] { r }, null); 2431 emitCC (ROOT, "fcmps `s0, `s1", null, new Temp[] { e1, e2 }); 2432 emitCC (ROOT, "nop", null, null); 2433 emitCC (ROOT, "fble "+templabel+"", null, null, new Label[] {templabel}); 2434 emitDELAYSLOT (ROOT); 2435 emit (ROOT, "mov 1, `d0", new Temp[] { r }, null); 2436 emitLABEL (ROOT, templabel + ":", templabel); 2437 return r; 2438 } 2439 } 2440 /* CONST<l,d>(c) */ 2441 if (true 2442 // check expression type 2443 && expArg instanceof harpoon.IR.Tree.CONST 2444 // check operand types 2445 && ( 2446 expArg.type() == Type.DOUBLE || 2447 expArg.type() == Type.LONG || 2448 false ) 2449 // end check operand types 2450 ){ 2451 Number c = ((harpoon.IR.Tree.CONST) expArg).value; 2452 harpoon.IR.Tree.CONST ROOT = (harpoon.IR.Tree.CONST) expArg; 2453 _matched_ = true; 2454 2455 if (_matched_) { // action code! degree: 1 2456 2457 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2458 clearDecl(); 2459 declare(r, code.getTreeDerivation(), ROOT); 2460 2461 // 'as' is smart - just use set, and it automagically generates 2462 // all of the necessary instructions 2463 long val = (ROOT.type() == Type.LONG) 2464 ? c.longValue() 2465 : Double.doubleToLongBits(c.floatValue()); 2466 int low = (int)val; 2467 int high = (int)(val >> 32); 2468 emit (ROOT, "set " + low + ", `d0l", new Temp[] { r }, null); 2469 emit (ROOT, "set " + high + ", `d0h", new Temp[] { r }, null); 2470 return r; 2471 } 2472 } 2473 /* CONST<i,f>(c) */ 2474 if (true 2475 // check expression type 2476 && expArg instanceof harpoon.IR.Tree.CONST 2477 // check operand types 2478 && ( 2479 expArg.type() == Type.FLOAT || 2480 ( expArg.type() == Type.INT && ! 2481 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2482 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2483 false ) 2484 // end check operand types 2485 ){ 2486 Number c = ((harpoon.IR.Tree.CONST) expArg).value; 2487 harpoon.IR.Tree.CONST ROOT = (harpoon.IR.Tree.CONST) expArg; 2488 _matched_ = true; 2489 2490 if (_matched_) { // action code! degree: 1 2491 2492 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2493 clearDecl(); 2494 declare(r, code.getTreeDerivation(), ROOT); 2495 2496 // 'as' is smart - just use set, and it automagically generates 2497 // all of the necessary instructions 2498 int val = (ROOT.type() == Type.INT) 2499 ? ROOT.value.intValue() 2500 : Float.floatToIntBits(ROOT.value.floatValue()); 2501 emit (ROOT, "set "+val+", `d0", new Temp[] { r }, null); 2502 return r; 2503 } 2504 } 2505 /* CONST<p>(c) */ 2506 if (true 2507 // check expression type 2508 && expArg instanceof harpoon.IR.Tree.CONST 2509 // check operand types 2510 && ( 2511 expArg.type() == Type.POINTER || 2512 false ) 2513 // end check operand types 2514 ){ 2515 Number c = ((harpoon.IR.Tree.CONST) expArg).value; 2516 harpoon.IR.Tree.CONST ROOT = (harpoon.IR.Tree.CONST) expArg; 2517 _matched_ = true; 2518 2519 if (_matched_) { // action code! degree: 1 2520 2521 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2522 clearDecl(); 2523 declare(r, code.getTreeDerivation(), ROOT); 2524 2525 declare(regg[0], HClass.Void); 2526 emit (ROOT, "mov `s0, `d0 ! null", new Temp[]{ r }, new Temp[] { regg[0] }); 2527 return r; 2528 } 2529 } 2530 /* CONST<i>(0) */ 2531 if (true 2532 // check expression type 2533 && expArg instanceof harpoon.IR.Tree.CONST 2534 // check operand types 2535 && ( 2536 ( expArg.type() == Type.INT && ! 2537 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2538 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2539 false ) 2540 // end check operand types 2541 // check that constant value matches 2542 && ( expArg.isFloatingPoint()? 2543 ((harpoon.IR.Tree.CONST)expArg).value.doubleValue() == 0.0: 2544 ((harpoon.IR.Tree.CONST)expArg).value.longValue() == 0) 2545 ){ 2546 harpoon.IR.Tree.CONST ROOT = (harpoon.IR.Tree.CONST) expArg; 2547 _matched_ = true; 2548 2549 if (_matched_) { // action code! degree: 1 2550 2551 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2552 clearDecl(); 2553 declare(r, code.getTreeDerivation(), ROOT); 2554 2555 declare(regg[0], HClass.Void); 2556 emit (ROOT, "mov `s0, `d0", new Temp[] { r }, new Temp[] { regg[0] }); 2557 return r; 2558 } 2559 } 2560 /* CONST<l>(0) */ 2561 if (true 2562 // check expression type 2563 && expArg instanceof harpoon.IR.Tree.CONST 2564 // check operand types 2565 && ( 2566 expArg.type() == Type.LONG || 2567 false ) 2568 // end check operand types 2569 // check that constant value matches 2570 && ( expArg.isFloatingPoint()? 2571 ((harpoon.IR.Tree.CONST)expArg).value.doubleValue() == 0.0: 2572 ((harpoon.IR.Tree.CONST)expArg).value.longValue() == 0) 2573 ){ 2574 harpoon.IR.Tree.CONST ROOT = (harpoon.IR.Tree.CONST) expArg; 2575 _matched_ = true; 2576 2577 if (_matched_) { // action code! degree: 1 2578 2579 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2580 clearDecl(); 2581 declare(r, code.getTreeDerivation(), ROOT); 2582 2583 declare(regg[0], HClass.Void); 2584 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { regg[0] }); 2585 emit (ROOT, "mov `s0, `d0h", new Temp[] { r }, new Temp[] { regg[0] }); 2586 return r; 2587 } 2588 } 2589 /* MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(e) */ 2590 if (true 2591 // check expression type 2592 && expArg instanceof harpoon.IR.Tree.MEM 2593 // check operand types 2594 && ( 2595 expArg.type() == Type.DOUBLE || 2596 expArg.type() == Type.FLOAT || 2597 expArg.type() == Type.LONG || 2598 expArg.type() == Type.POINTER || 2599 ( expArg.type() == Type.INT && ! 2600 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2601 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2602 (((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall() && ( 2603 ((harpoon.IR.Tree.PreciselyTyped)expArg).signed() ? ( 2604 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 2605 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 2606 false) : ( 2607 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==8 || 2608 ((harpoon.IR.Tree.PreciselyTyped)expArg).bitwidth()==16 || 2609 false) ) ) || 2610 false ) 2611 // end check operand types 2612 // check child 2613 // no check needed for ExpId children 2614 ){ 2615 harpoon.IR.Tree.MEM ROOT = (harpoon.IR.Tree.MEM) expArg; 2616 _matched_ = true; 2617 2618 if (_matched_) { // action code! degree: 1 2619 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.MEM)expArg).getExp()); 2620 2621 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2622 clearDecl(); 2623 declare(r, code.getTreeDerivation(), ROOT); 2624 2625 String srcsuff = (ROOT.isDoubleWord()) ? "h" : ""; 2626 emit (ROOT, "ld"+loadSuffix(ROOT) + " [`s0], `d0"+srcsuff + "", 2627 new Temp[] { r }, new Temp[] { e }); 2628 return r; 2629 } 2630 } 2631 /* NAME(s) */ 2632 if (true 2633 // check expression type 2634 && expArg instanceof harpoon.IR.Tree.NAME 2635 ){ 2636 harpoon.Temp.Label s = ((harpoon.IR.Tree.NAME)expArg).label; 2637 harpoon.IR.Tree.NAME ROOT = (harpoon.IR.Tree.NAME) expArg; 2638 _matched_ = true; 2639 2640 if (_matched_) { // action code! degree: 1 2641 2642 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2643 clearDecl(); 2644 declare(r, code.getTreeDerivation(), ROOT); 2645 2646 emit (ROOT, "set " + s + ", `d0", new Temp[] { r }, null); 2647 return r; 2648 } 2649 } 2650 /* TEMP<i,l,f,d,p>(id) */ 2651 if (true 2652 // check expression type 2653 && expArg instanceof harpoon.IR.Tree.TEMP 2654 // check operand types 2655 && ( 2656 expArg.type() == Type.DOUBLE || 2657 expArg.type() == Type.FLOAT || 2658 expArg.type() == Type.LONG || 2659 expArg.type() == Type.POINTER || 2660 ( expArg.type() == Type.INT && ! 2661 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2662 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2663 false ) 2664 // end check operand types 2665 ){ 2666 harpoon.Temp.Temp id = makeTemp((harpoon.IR.Tree.TEMP)expArg, inf.tempFactory()); 2667 harpoon.IR.Tree.TEMP ROOT = (harpoon.IR.Tree.TEMP) expArg; 2668 _matched_ = true; 2669 2670 if (_matched_) { // action code! degree: 1 2671 2672 Temp i = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2673 clearDecl(); 2674 declare(i, code.getTreeDerivation(), ROOT); 2675 2676 i = makeTemp(ROOT, id, inf.tempFactory()); 2677 return i; 2678 } 2679 } 2680 /* UNOP<i,p>(NEG,e) */ 2681 if (true 2682 // check expression type 2683 && expArg instanceof harpoon.IR.Tree.UNOP 2684 // check opcode 2685 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop.NEG 2686 // check operand types 2687 && ( 2688 expArg.type() == Type.POINTER || 2689 ( expArg.type() == Type.INT && ! 2690 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2691 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2692 false ) 2693 // end check operand types 2694 // check child 2695 // no check needed for ExpId children 2696 ){ 2697 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2698 _matched_ = true; 2699 2700 if (_matched_) { // action code! degree: 1 2701 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2702 2703 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2704 clearDecl(); 2705 declare(r, code.getTreeDerivation(), ROOT); 2706 2707 declare(regg[0], HClass.Int); 2708 emit (ROOT, "sub `s0, `s1, `d0", new Temp[] { r }, new Temp[] { regg[0], e }); 2709 return r; 2710 } 2711 } 2712 /* UNOP<l>(NEG,e) */ 2713 if (true 2714 // check expression type 2715 && expArg instanceof harpoon.IR.Tree.UNOP 2716 // check opcode 2717 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop.NEG 2718 // check operand types 2719 && ( 2720 expArg.type() == Type.LONG || 2721 false ) 2722 // end check operand types 2723 // check child 2724 // no check needed for ExpId children 2725 ){ 2726 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2727 _matched_ = true; 2728 2729 if (_matched_) { // action code! degree: 1 2730 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2731 2732 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2733 clearDecl(); 2734 declare(r, code.getTreeDerivation(), ROOT); 2735 2736 declare(regg[0], HClass.Int); 2737 emitCC (ROOT, "subcc `s0, `s1l, `d0l", 2738 new Temp[] { r }, new Temp[] { regg[0], e }); 2739 emitCC (ROOT, "subx `s0, `s1h, `d0h", 2740 new Temp[] { r }, new Temp[] { regg[0], e }); 2741 return r; 2742 } 2743 } 2744 /* UNOP<f>(NEG,e) */ 2745 if (true 2746 // check expression type 2747 && expArg instanceof harpoon.IR.Tree.UNOP 2748 // check opcode 2749 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop.NEG 2750 // check operand types 2751 && ( 2752 expArg.type() == Type.FLOAT || 2753 false ) 2754 // end check operand types 2755 // check child 2756 // no check needed for ExpId children 2757 ){ 2758 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2759 _matched_ = true; 2760 2761 if (_matched_) { // action code! degree: 1 2762 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2763 2764 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2765 clearDecl(); 2766 declare(r, code.getTreeDerivation(), ROOT); 2767 2768 emit (ROOT, "fnegs `s0, `d0", new Temp[] { r }, new Temp[] { e }); 2769 return r; 2770 } 2771 } 2772 /* UNOP<i,l,f,d,p>(I2B,e) */ 2773 if (true 2774 // check expression type 2775 && expArg instanceof harpoon.IR.Tree.UNOP 2776 // check opcode 2777 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop.I2B 2778 // check operand types 2779 && ( 2780 expArg.type() == Type.DOUBLE || 2781 expArg.type() == Type.FLOAT || 2782 expArg.type() == Type.LONG || 2783 expArg.type() == Type.POINTER || 2784 ( expArg.type() == Type.INT && ! 2785 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2786 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2787 false ) 2788 // end check operand types 2789 // check child 2790 // no check needed for ExpId children 2791 ){ 2792 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2793 _matched_ = true&& (ROOT.operandType() == Type.INT); 2794 2795 if (_matched_) { // action code! degree: 1 2796 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2797 2798 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2799 clearDecl(); 2800 declare(r, code.getTreeDerivation(), ROOT); 2801 2802 emit (ROOT, "sll `s0, 24, `d0", new Temp[] { r }, new Temp[] { e }); 2803 emit (ROOT, "sra `s0, 24, `d0", new Temp[] { r }, new Temp[] { e }); 2804 return r; 2805 } 2806 } 2807 /* UNOP<i,l,f,d,p>(I2C,e) */ 2808 if (true 2809 // check expression type 2810 && expArg instanceof harpoon.IR.Tree.UNOP 2811 // check opcode 2812 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop.I2C 2813 // check operand types 2814 && ( 2815 expArg.type() == Type.DOUBLE || 2816 expArg.type() == Type.FLOAT || 2817 expArg.type() == Type.LONG || 2818 expArg.type() == Type.POINTER || 2819 ( expArg.type() == Type.INT && ! 2820 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2821 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2822 false ) 2823 // end check operand types 2824 // check child 2825 // no check needed for ExpId children 2826 ){ 2827 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2828 _matched_ = true&& (ROOT.operandType() == Type.INT); 2829 2830 if (_matched_) { // action code! degree: 1 2831 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2832 2833 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2834 clearDecl(); 2835 declare(r, code.getTreeDerivation(), ROOT); 2836 2837 emit (ROOT, "sll `s0, 16, `d0", new Temp[] { r }, new Temp[] { e }); 2838 emit (ROOT, "sra `s0, 16, `d0", new Temp[] { r }, new Temp[] { e }); 2839 return r; 2840 } 2841 } 2842 /* UNOP<i,l,f,d,p>(I2S,e) */ 2843 if (true 2844 // check expression type 2845 && expArg instanceof harpoon.IR.Tree.UNOP 2846 // check opcode 2847 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop.I2S 2848 // check operand types 2849 && ( 2850 expArg.type() == Type.DOUBLE || 2851 expArg.type() == Type.FLOAT || 2852 expArg.type() == Type.LONG || 2853 expArg.type() == Type.POINTER || 2854 ( expArg.type() == Type.INT && ! 2855 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2856 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2857 false ) 2858 // end check operand types 2859 // check child 2860 // no check needed for ExpId children 2861 ){ 2862 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2863 _matched_ = true&& (ROOT.operandType() == Type.INT); 2864 2865 if (_matched_) { // action code! degree: 1 2866 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2867 2868 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2869 clearDecl(); 2870 declare(r, code.getTreeDerivation(), ROOT); 2871 2872 emit (ROOT, "sll `s0, 16, `d0", new Temp[] { r }, new Temp[] { e }); 2873 emit (ROOT, "srl `s0, 16, `d0", new Temp[] { r }, new Temp[] { e }); 2874 return r; 2875 } 2876 } 2877 /* UNOP<i,l,f,d,p>(_2I,e) */ 2878 if (true 2879 // check expression type 2880 && expArg instanceof harpoon.IR.Tree.UNOP 2881 // check opcode 2882 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop._2I 2883 // check operand types 2884 && ( 2885 expArg.type() == Type.DOUBLE || 2886 expArg.type() == Type.FLOAT || 2887 expArg.type() == Type.LONG || 2888 expArg.type() == Type.POINTER || 2889 ( expArg.type() == Type.INT && ! 2890 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2891 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2892 false ) 2893 // end check operand types 2894 // check child 2895 // no check needed for ExpId children 2896 ){ 2897 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2898 _matched_ = true&& (ROOT.operandType() == Type.FLOAT ); 2899 2900 if (_matched_) { // action code! degree: 1 2901 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2902 2903 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2904 clearDecl(); 2905 declare(r, code.getTreeDerivation(), ROOT); 2906 2907 emit (ROOT, "fstoi `s0, `d0", new Temp[] { r }, new Temp[] { e }); 2908 return r; 2909 } 2910 } 2911 /* UNOP<i,l,f,d,p>(_2I,e) */ 2912 if (true 2913 // check expression type 2914 && expArg instanceof harpoon.IR.Tree.UNOP 2915 // check opcode 2916 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop._2I 2917 // check operand types 2918 && ( 2919 expArg.type() == Type.DOUBLE || 2920 expArg.type() == Type.FLOAT || 2921 expArg.type() == Type.LONG || 2922 expArg.type() == Type.POINTER || 2923 ( expArg.type() == Type.INT && ! 2924 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2925 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2926 false ) 2927 // end check operand types 2928 // check child 2929 // no check needed for ExpId children 2930 ){ 2931 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2932 _matched_ = true&& (ROOT.operandType() == Type.LONG ); 2933 2934 if (_matched_) { // action code! degree: 1 2935 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2936 2937 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2938 clearDecl(); 2939 declare(r, code.getTreeDerivation(), ROOT); 2940 2941 emit (ROOT, "mov `s0l, `d0", new Temp[] { r } , new Temp[] { e }); 2942 return r; 2943 } 2944 } 2945 /* UNOP<i,l,f,d,p>(_2I,e) */ 2946 if (true 2947 // check expression type 2948 && expArg instanceof harpoon.IR.Tree.UNOP 2949 // check opcode 2950 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop._2I 2951 // check operand types 2952 && ( 2953 expArg.type() == Type.DOUBLE || 2954 expArg.type() == Type.FLOAT || 2955 expArg.type() == Type.LONG || 2956 expArg.type() == Type.POINTER || 2957 ( expArg.type() == Type.INT && ! 2958 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2959 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2960 false ) 2961 // end check operand types 2962 // check child 2963 // no check needed for ExpId children 2964 ){ 2965 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 2966 _matched_ = true&& (ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 2967 2968 if (_matched_) { // action code! degree: 1 2969 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 2970 2971 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 2972 clearDecl(); 2973 declare(r, code.getTreeDerivation(), ROOT); 2974 2975 emit (ROOT, "mov `s0, `d0", new Temp[] { r } , new Temp[] { e }); 2976 return r; 2977 } 2978 } 2979 /* UNOP<i,l,f,d,p>(_2L,e) */ 2980 if (true 2981 // check expression type 2982 && expArg instanceof harpoon.IR.Tree.UNOP 2983 // check opcode 2984 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop._2L 2985 // check operand types 2986 && ( 2987 expArg.type() == Type.DOUBLE || 2988 expArg.type() == Type.FLOAT || 2989 expArg.type() == Type.LONG || 2990 expArg.type() == Type.POINTER || 2991 ( expArg.type() == Type.INT && ! 2992 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 2993 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 2994 false ) 2995 // end check operand types 2996 // check child 2997 // no check needed for ExpId children 2998 ){ 2999 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 3000 _matched_ = true&& (ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 3001 3002 if (_matched_) { // action code! degree: 1 3003 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 3004 3005 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 3006 clearDecl(); 3007 declare(r, code.getTreeDerivation(), ROOT); 3008 3009 emit (ROOT, "mov `s0, `d0l", new Temp[] { r }, new Temp[] { e }); 3010 emit (ROOT, "sra `s0, 31, `d0h", new Temp[] { r } , new Temp[] { e }); 3011 return r; 3012 } 3013 } 3014 /* UNOP<i,l,f,d,p>(_2F,e) */ 3015 if (true 3016 // check expression type 3017 && expArg instanceof harpoon.IR.Tree.UNOP 3018 // check opcode 3019 && ((harpoon.IR.Tree.UNOP)expArg).op == harpoon.IR.Tree.Uop._2F 3020 // check operand types 3021 && ( 3022 expArg.type() == Type.DOUBLE || 3023 expArg.type() == Type.FLOAT || 3024 expArg.type() == Type.LONG || 3025 expArg.type() == Type.POINTER || 3026 ( expArg.type() == Type.INT && ! 3027 (expArg instanceof harpoon.IR.Tree.PreciselyTyped && 3028 ((harpoon.IR.Tree.PreciselyTyped)expArg).isSmall())) || 3029 false ) 3030 // end check operand types 3031 // check child 3032 // no check needed for ExpId children 3033 ){ 3034 harpoon.IR.Tree.UNOP ROOT = (harpoon.IR.Tree.UNOP) expArg; 3035 _matched_ = true&& (ROOT.operandType() == Type.INT || ROOT.operandType() == Type.POINTER); 3036 3037 if (_matched_) { // action code! degree: 1 3038 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.UNOP)expArg).getOperand()); 3039 3040 Temp r = frame.getTempBuilder().makeTemp( ROOT , inf.tempFactory()); 3041 clearDecl(); 3042 declare(r, code.getTreeDerivation(), ROOT); 3043 3044 /* AAA - this is broken. need to do loads and stores, can't 3045 move directly from fp to normal registers. */ 3046 emit (ROOT, "fitos `s0, `d0", new Temp[] { r }, new Temp[] { e }); 3047 return r; 3048 } 3049 } 3050 assert false : "Uh oh...\nmaximal munch didn't match anything...SPEC file\nis not complete enough for this program\nDied on "+prettyPrint(expArg)+" in " + prettyPrint(globalStmArg); 3051 return null; // doesn't matter, we're dead if we didn't match... 3052 } // end munchExp 3053 harpoon.IR.Tree.Stm globalStmArg=null; 3054 void munchStm(harpoon.IR.Tree.Stm stmArg) { 3055 globalStmArg = stmArg; 3056 boolean _matched_ = false; 3057 clearDecl(); // reset temp type mappings 3058 /* MOVE<i,l,f,d,p>(MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(ADD,CONST<i>(c),e1)),e2) */ 3059 if (true 3060 // check statement type 3061 && stmArg instanceof harpoon.IR.Tree.MOVE 3062 // check operand types 3063 && ( 3064 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 3065 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 3066 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 3067 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 3068 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 3069 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 3070 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 3071 false ) 3072 // end check operand types 3073 && (true 3074 // no check needed for ExpId children 3075 ) 3076 && (true 3077 // check expression type 3078 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.MEM 3079 // check operand types 3080 && ( 3081 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 3082 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 3083 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 3084 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 3085 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 3086 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 3087 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 3088 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall() && ( 3089 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).signed() ? ( 3090 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3091 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3092 false) : ( 3093 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3094 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3095 false) ) ) || 3096 false ) 3097 // end check operand types 3098 // check child 3099 // check expression type 3100 && ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.BINOP 3101 // check opcode 3102 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).op == harpoon.IR.Tree.Bop.ADD 3103 // check operand types 3104 && ( 3105 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.DOUBLE || 3106 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.FLOAT || 3107 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.LONG || 3108 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.POINTER || 3109 ( ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.INT && ! 3110 (((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3111 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).isSmall())) || 3112 false ) 3113 // end check operand types 3114 // check left child 3115 // check expression type 3116 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft() instanceof harpoon.IR.Tree.CONST 3117 // check operand types 3118 && ( 3119 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft().type() == Type.INT && ! 3120 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft() instanceof harpoon.IR.Tree.PreciselyTyped && 3121 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft()).isSmall())) || 3122 false ) 3123 // end check operand types 3124 // check right child 3125 // no check needed for ExpId children 3126 ) 3127 ){ 3128 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft()).value; 3129 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 3130 _matched_ = true&& ( is13bit(c) ); 3131 3132 if (_matched_) { // action code! : degree 4 3133 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 3134 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight()); 3135 3136 3137 MEM dst = (MEM)(((MOVE)ROOT).getDst()); 3138 String suff = (dst.isDoubleWord()) ? "h" : ""; 3139 emitMEM (ROOT, "st"+storeSuffix(dst) + " `s1"+suff + ", [ `s0 + "+c+" ]", 3140 null, new Temp[] { e1, e2 }); 3141 return; } 3142 } 3143 /* MOVE<i,l,f,d,p>(MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(ADD,e1,CONST<i>(c))),e2) */ 3144 if (true 3145 // check statement type 3146 && stmArg instanceof harpoon.IR.Tree.MOVE 3147 // check operand types 3148 && ( 3149 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 3150 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 3151 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 3152 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 3153 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 3154 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 3155 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 3156 false ) 3157 // end check operand types 3158 && (true 3159 // no check needed for ExpId children 3160 ) 3161 && (true 3162 // check expression type 3163 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.MEM 3164 // check operand types 3165 && ( 3166 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 3167 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 3168 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 3169 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 3170 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 3171 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 3172 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 3173 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall() && ( 3174 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).signed() ? ( 3175 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3176 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3177 false) : ( 3178 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3179 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3180 false) ) ) || 3181 false ) 3182 // end check operand types 3183 // check child 3184 // check expression type 3185 && ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.BINOP 3186 // check opcode 3187 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).op == harpoon.IR.Tree.Bop.ADD 3188 // check operand types 3189 && ( 3190 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.DOUBLE || 3191 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.FLOAT || 3192 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.LONG || 3193 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.POINTER || 3194 ( ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.INT && ! 3195 (((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3196 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).isSmall())) || 3197 false ) 3198 // end check operand types 3199 // check left child 3200 // no check needed for ExpId children 3201 // check right child 3202 // check expression type 3203 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight() instanceof harpoon.IR.Tree.CONST 3204 // check operand types 3205 && ( 3206 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight().type() == Type.INT && ! 3207 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 3208 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight()).isSmall())) || 3209 false ) 3210 // end check operand types 3211 ) 3212 ){ 3213 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight()).value; 3214 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 3215 _matched_ = true&& ( is13bit(c) ); 3216 3217 if (_matched_) { // action code! : degree 4 3218 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 3219 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft()); 3220 3221 3222 MEM dst = (MEM)(((MOVE)ROOT).getDst()); 3223 String suff = (dst.isDoubleWord()) ? "h" : ""; 3224 emitMEM (ROOT, "st"+storeSuffix(dst) + " `s1"+suff + ", [ `s0 + "+c+" ]", 3225 null, new Temp[] { e1, e2 }); 3226 return; } 3227 } 3228 /* MOVE<i,l,f,d,p>(MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(ADD,e1,CONST<i>(c))),e2) */ 3229 if (true 3230 // check statement type 3231 && stmArg instanceof harpoon.IR.Tree.MOVE 3232 // check operand types 3233 && ( 3234 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 3235 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 3236 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 3237 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 3238 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 3239 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 3240 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 3241 false ) 3242 // end check operand types 3243 && (true 3244 // no check needed for ExpId children 3245 ) 3246 && (true 3247 // check expression type 3248 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.MEM 3249 // check operand types 3250 && ( 3251 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 3252 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 3253 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 3254 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 3255 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 3256 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 3257 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 3258 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall() && ( 3259 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).signed() ? ( 3260 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3261 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3262 false) : ( 3263 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3264 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3265 false) ) ) || 3266 false ) 3267 // end check operand types 3268 // check child 3269 // check expression type 3270 && ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.BINOP 3271 // check opcode 3272 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).op == harpoon.IR.Tree.Bop.ADD 3273 // check operand types 3274 && ( 3275 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.DOUBLE || 3276 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.FLOAT || 3277 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.LONG || 3278 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.POINTER || 3279 ( ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.INT && ! 3280 (((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3281 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).isSmall())) || 3282 false ) 3283 // end check operand types 3284 // check left child 3285 // no check needed for ExpId children 3286 // check right child 3287 // check expression type 3288 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight() instanceof harpoon.IR.Tree.CONST 3289 // check operand types 3290 && ( 3291 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight().type() == Type.INT && ! 3292 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 3293 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight()).isSmall())) || 3294 false ) 3295 // end check operand types 3296 ) 3297 ){ 3298 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight()).value; 3299 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 3300 _matched_ = true&& ( is13bit(c) ); 3301 3302 if (_matched_) { // action code! : degree 4 3303 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 3304 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft()); 3305 3306 3307 MEM dst = (MEM)(((MOVE)ROOT).getDst()); 3308 String suff = (dst.isDoubleWord()) ? "h" : ""; 3309 emitMEM (ROOT, "st"+storeSuffix(dst) + " `s1"+suff + ", [ `s0 + "+c+" ]", 3310 null, new Temp[] { e1, e2 }); 3311 return; } 3312 } 3313 /* MOVE<i,l,f,d,p>(MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(ADD,CONST<i>(c),e1)),e2) */ 3314 if (true 3315 // check statement type 3316 && stmArg instanceof harpoon.IR.Tree.MOVE 3317 // check operand types 3318 && ( 3319 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 3320 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 3321 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 3322 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 3323 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 3324 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 3325 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 3326 false ) 3327 // end check operand types 3328 && (true 3329 // no check needed for ExpId children 3330 ) 3331 && (true 3332 // check expression type 3333 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.MEM 3334 // check operand types 3335 && ( 3336 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 3337 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 3338 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 3339 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 3340 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 3341 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 3342 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 3343 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall() && ( 3344 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).signed() ? ( 3345 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3346 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3347 false) : ( 3348 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3349 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3350 false) ) ) || 3351 false ) 3352 // end check operand types 3353 // check child 3354 // check expression type 3355 && ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.BINOP 3356 // check opcode 3357 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).op == harpoon.IR.Tree.Bop.ADD 3358 // check operand types 3359 && ( 3360 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.DOUBLE || 3361 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.FLOAT || 3362 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.LONG || 3363 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.POINTER || 3364 ( ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.INT && ! 3365 (((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3366 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).isSmall())) || 3367 false ) 3368 // end check operand types 3369 // check left child 3370 // check expression type 3371 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft() instanceof harpoon.IR.Tree.CONST 3372 // check operand types 3373 && ( 3374 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft().type() == Type.INT && ! 3375 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft() instanceof harpoon.IR.Tree.PreciselyTyped && 3376 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft()).isSmall())) || 3377 false ) 3378 // end check operand types 3379 // check right child 3380 // no check needed for ExpId children 3381 ) 3382 ){ 3383 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft()).value; 3384 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 3385 _matched_ = true&& ( is13bit(c) ); 3386 3387 if (_matched_) { // action code! : degree 4 3388 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 3389 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight()); 3390 3391 3392 MEM dst = (MEM)(((MOVE)ROOT).getDst()); 3393 String suff = (dst.isDoubleWord()) ? "h" : ""; 3394 emitMEM (ROOT, "st"+storeSuffix(dst) + " `s1"+suff + ", [ `s0 + "+c+" ]", 3395 null, new Temp[] { e1, e2 }); 3396 return; } 3397 } 3398 /* JUMP(BINOP<i,l,f,d,p>(ADD,e,CONST<i>(c))) */ 3399 if (true 3400 // check statement type 3401 && stmArg instanceof harpoon.IR.Tree.JUMP 3402 && (true 3403 // check expression type 3404 && ((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.BINOP 3405 // check opcode 3406 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).op == harpoon.IR.Tree.Bop.ADD 3407 // check operand types 3408 && ( 3409 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.DOUBLE || 3410 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.FLOAT || 3411 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.LONG || 3412 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.POINTER || 3413 ( ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.INT && ! 3414 (((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3415 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.JUMP)stmArg).getExp()).isSmall())) || 3416 false ) 3417 // end check operand types 3418 // check left child 3419 // no check needed for ExpId children 3420 // check right child 3421 // check expression type 3422 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight() instanceof harpoon.IR.Tree.CONST 3423 // check operand types 3424 && ( 3425 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight().type() == Type.INT && ! 3426 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 3427 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight()).isSmall())) || 3428 false ) 3429 // end check operand types 3430 ) 3431 ){ 3432 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight()).value; 3433 harpoon.IR.Tree.JUMP ROOT = (harpoon.IR.Tree.JUMP) stmArg; 3434 _matched_ = true&& ( is13bit(c) ); 3435 3436 if (_matched_) { // action code! : degree 3 3437 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft()); 3438 3439 3440 List<Label> labelList = LabelList.toList (ROOT.targets); 3441 emitNoFall (ROOT, "jmpl `s0 + "+c+", %g0", 3442 null, new Temp[] { e }, labelList); 3443 emitDELAYSLOT (ROOT); 3444 return; } 3445 } 3446 /* JUMP(BINOP<i,l,f,d,p>(ADD,CONST<i>(c),e)) */ 3447 if (true 3448 // check statement type 3449 && stmArg instanceof harpoon.IR.Tree.JUMP 3450 && (true 3451 // check expression type 3452 && ((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.BINOP 3453 // check opcode 3454 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).op == harpoon.IR.Tree.Bop.ADD 3455 // check operand types 3456 && ( 3457 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.DOUBLE || 3458 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.FLOAT || 3459 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.LONG || 3460 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.POINTER || 3461 ( ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.INT && ! 3462 (((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3463 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.JUMP)stmArg).getExp()).isSmall())) || 3464 false ) 3465 // end check operand types 3466 // check left child 3467 // check expression type 3468 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft() instanceof harpoon.IR.Tree.CONST 3469 // check operand types 3470 && ( 3471 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft().type() == Type.INT && ! 3472 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft() instanceof harpoon.IR.Tree.PreciselyTyped && 3473 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft()).isSmall())) || 3474 false ) 3475 // end check operand types 3476 // check right child 3477 // no check needed for ExpId children 3478 ) 3479 ){ 3480 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft()).value; 3481 harpoon.IR.Tree.JUMP ROOT = (harpoon.IR.Tree.JUMP) stmArg; 3482 _matched_ = true&& ( is13bit(c) ); 3483 3484 if (_matched_) { // action code! : degree 3 3485 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight()); 3486 3487 3488 List<Label> labelList = LabelList.toList (ROOT.targets); 3489 emitNoFall (ROOT, "jmpl `s0 + "+c+", %g0", 3490 null, new Temp[] { e }, labelList); 3491 emitDELAYSLOT (ROOT); 3492 return; } 3493 } 3494 /* JUMP(BINOP<i,l,f,d,p>(ADD,CONST<i>(c),e)) */ 3495 if (true 3496 // check statement type 3497 && stmArg instanceof harpoon.IR.Tree.JUMP 3498 && (true 3499 // check expression type 3500 && ((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.BINOP 3501 // check opcode 3502 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).op == harpoon.IR.Tree.Bop.ADD 3503 // check operand types 3504 && ( 3505 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.DOUBLE || 3506 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.FLOAT || 3507 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.LONG || 3508 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.POINTER || 3509 ( ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.INT && ! 3510 (((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3511 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.JUMP)stmArg).getExp()).isSmall())) || 3512 false ) 3513 // end check operand types 3514 // check left child 3515 // check expression type 3516 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft() instanceof harpoon.IR.Tree.CONST 3517 // check operand types 3518 && ( 3519 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft().type() == Type.INT && ! 3520 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft() instanceof harpoon.IR.Tree.PreciselyTyped && 3521 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft()).isSmall())) || 3522 false ) 3523 // end check operand types 3524 // check right child 3525 // no check needed for ExpId children 3526 ) 3527 ){ 3528 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft()).value; 3529 harpoon.IR.Tree.JUMP ROOT = (harpoon.IR.Tree.JUMP) stmArg; 3530 _matched_ = true&& ( is13bit(c) ); 3531 3532 if (_matched_) { // action code! : degree 3 3533 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight()); 3534 3535 3536 List<Label> labelList = LabelList.toList (ROOT.targets); 3537 emitNoFall (ROOT, "jmpl `s0 + "+c+", %g0", 3538 null, new Temp[] { e }, labelList); 3539 emitDELAYSLOT (ROOT); 3540 return; } 3541 } 3542 /* JUMP(BINOP<i,l,f,d,p>(ADD,e,CONST<i>(c))) */ 3543 if (true 3544 // check statement type 3545 && stmArg instanceof harpoon.IR.Tree.JUMP 3546 && (true 3547 // check expression type 3548 && ((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.BINOP 3549 // check opcode 3550 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).op == harpoon.IR.Tree.Bop.ADD 3551 // check operand types 3552 && ( 3553 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.DOUBLE || 3554 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.FLOAT || 3555 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.LONG || 3556 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.POINTER || 3557 ( ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.INT && ! 3558 (((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3559 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.JUMP)stmArg).getExp()).isSmall())) || 3560 false ) 3561 // end check operand types 3562 // check left child 3563 // no check needed for ExpId children 3564 // check right child 3565 // check expression type 3566 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight() instanceof harpoon.IR.Tree.CONST 3567 // check operand types 3568 && ( 3569 ( ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight().type() == Type.INT && ! 3570 (((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight() instanceof harpoon.IR.Tree.PreciselyTyped && 3571 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight()).isSmall())) || 3572 false ) 3573 // end check operand types 3574 ) 3575 ){ 3576 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight()).value; 3577 harpoon.IR.Tree.JUMP ROOT = (harpoon.IR.Tree.JUMP) stmArg; 3578 _matched_ = true&& ( is13bit(c) ); 3579 3580 if (_matched_) { // action code! : degree 3 3581 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft()); 3582 3583 3584 List<Label> labelList = LabelList.toList (ROOT.targets); 3585 emitNoFall (ROOT, "jmpl `s0 + "+c+", %g0", 3586 null, new Temp[] { e }, labelList); 3587 emitDELAYSLOT (ROOT); 3588 return; } 3589 } 3590 /* MOVE<i,l,f,d,p>(MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(BINOP<i,l,f,d,p>(ADD,e1,e2)),e3) */ 3591 if (true 3592 // check statement type 3593 && stmArg instanceof harpoon.IR.Tree.MOVE 3594 // check operand types 3595 && ( 3596 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 3597 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 3598 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 3599 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 3600 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 3601 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 3602 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 3603 false ) 3604 // end check operand types 3605 && (true 3606 // no check needed for ExpId children 3607 ) 3608 && (true 3609 // check expression type 3610 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.MEM 3611 // check operand types 3612 && ( 3613 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 3614 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 3615 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 3616 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 3617 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 3618 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 3619 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 3620 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall() && ( 3621 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).signed() ? ( 3622 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3623 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3624 false) : ( 3625 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3626 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3627 false) ) ) || 3628 false ) 3629 // end check operand types 3630 // check child 3631 // check expression type 3632 && ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.BINOP 3633 // check opcode 3634 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).op == harpoon.IR.Tree.Bop.ADD 3635 // check operand types 3636 && ( 3637 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.DOUBLE || 3638 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.FLOAT || 3639 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.LONG || 3640 ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.POINTER || 3641 ( ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.INT && ! 3642 (((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3643 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).isSmall())) || 3644 false ) 3645 // end check operand types 3646 // check left child 3647 // no check needed for ExpId children 3648 // check right child 3649 // no check needed for ExpId children 3650 ) 3651 ){ 3652 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 3653 _matched_ = true; 3654 3655 if (_matched_) { // action code! : degree 3 3656 harpoon.Temp.Temp e3 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 3657 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getLeft()); 3658 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).getRight()); 3659 3660 3661 MEM dst = (MEM)(((MOVE)ROOT).getDst()); 3662 String suff = (dst.isDoubleWord()) ? "h" : ""; 3663 emitMEM (ROOT, "st"+storeSuffix(dst) + " `s2"+suff + ", [`s0 + `s1]", 3664 null, new Temp[] { e1, e2, e3 }); 3665 return; } 3666 } 3667 /* MOVE<i,l,f,d,p>(MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(CONST<i>(c)),e) */ 3668 if (true 3669 // check statement type 3670 && stmArg instanceof harpoon.IR.Tree.MOVE 3671 // check operand types 3672 && ( 3673 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 3674 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 3675 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 3676 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 3677 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 3678 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 3679 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 3680 false ) 3681 // end check operand types 3682 && (true 3683 // no check needed for ExpId children 3684 ) 3685 && (true 3686 // check expression type 3687 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.MEM 3688 // check operand types 3689 && ( 3690 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 3691 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 3692 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 3693 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 3694 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 3695 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 3696 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 3697 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall() && ( 3698 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).signed() ? ( 3699 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3700 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3701 false) : ( 3702 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 3703 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 3704 false) ) ) || 3705 false ) 3706 // end check operand types 3707 // check child 3708 // check expression type 3709 && ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.CONST 3710 // check operand types 3711 && ( 3712 ( ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp().type() == Type.INT && ! 3713 (((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 3714 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).isSmall())) || 3715 false ) 3716 // end check operand types 3717 ) 3718 ){ 3719 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()).value; 3720 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 3721 _matched_ = true&& ( is13bit(c) ); 3722 3723 if (_matched_) { // action code! : degree 3 3724 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 3725 3726 3727 MEM dst = (MEM)(((MOVE)ROOT).getDst()); 3728 String suff = (dst.isDoubleWord()) ? "h" : ""; 3729 emitMEM (ROOT, "st"+storeSuffix(dst) + " `s0"+suff + ", [ "+c+" ]", 3730 null, new Temp[] { e }); 3731 return; } 3732 } 3733 /* MOVE<i,p>(TEMP<i,l,f,d,p>(e1),CONST<i>(c)) */ 3734 if (true 3735 // check statement type 3736 && stmArg instanceof harpoon.IR.Tree.MOVE 3737 // check operand types 3738 && ( 3739 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 3740 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 3741 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 3742 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 3743 false ) 3744 // end check operand types 3745 && (true 3746 // check expression type 3747 && ((harpoon.IR.Tree.MOVE) stmArg).getSrc() instanceof harpoon.IR.Tree.CONST 3748 // check operand types 3749 && ( 3750 ( ((harpoon.IR.Tree.MOVE) stmArg).getSrc().type() == Type.INT && ! 3751 (((harpoon.IR.Tree.MOVE) stmArg).getSrc() instanceof harpoon.IR.Tree.PreciselyTyped && 3752 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getSrc()).isSmall())) || 3753 false ) 3754 // end check operand types 3755 ) 3756 && (true 3757 // check expression type 3758 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.TEMP 3759 // check operand types 3760 && ( 3761 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 3762 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 3763 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 3764 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 3765 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 3766 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 3767 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 3768 false ) 3769 // end check operand types 3770 ) 3771 ){ 3772 Number c = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.MOVE) stmArg).getSrc()).value; 3773 harpoon.Temp.Temp e1 = makeTemp((harpoon.IR.Tree.TEMP)((harpoon.IR.Tree.MOVE) stmArg).getDst(), inf.tempFactory()); 3774 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 3775 _matched_ = true&& ( is13bit(c) ); 3776 3777 if (_matched_) { // action code! : degree 3 3778 3779 3780 declare(e1, code.getTreeDerivation(), ROOT.getSrc()); 3781 emit (ROOT, "mov "+c+", `d0", 3782 new Temp[] { e1 }, null); 3783 return; } 3784 } 3785 /* CALL(retval,retex,NAME(func),arglist,handler) */ 3786 if (true 3787 // check statement type 3788 && stmArg instanceof harpoon.IR.Tree.CALL 3789 && (true 3790 // check expression type 3791 && ((harpoon.IR.Tree.CALL) stmArg).getFunc() instanceof harpoon.IR.Tree.NAME 3792 ) 3793 ){ 3794 harpoon.Temp.Label func = ((harpoon.IR.Tree.NAME)((harpoon.IR.Tree.CALL) stmArg).getFunc()).label; 3795 harpoon.Temp.Label handler = ((harpoon.IR.Tree.CALL)stmArg).getHandler().label; 3796 harpoon.IR.Tree.CALL ROOT = (harpoon.IR.Tree.CALL) stmArg; 3797 _matched_ = true&& ( !ROOT.isTailCall ); 3798 3799 if (_matched_) { // action code! : degree 2 3800 harpoon.Temp.Temp retval = (((harpoon.IR.Tree.CALL)stmArg).getRetval()==null) ? null : munchExp(((harpoon.IR.Tree.CALL)stmArg).getRetval()); 3801 harpoon.Temp.Temp retex = munchExp(((harpoon.IR.Tree.CALL)stmArg).getRetex()); 3802 /* munch argument ExpList into a TempList */ 3803 harpoon.Temp.TempList arglist = new harpoon.Temp.TempList(null, null); 3804 { harpoon.Temp.TempList tl=arglist; 3805 for (harpoon.IR.Tree.ExpList el = ((harpoon.IR.Tree.CALL)stmArg).getArgs(); el!=null; el=el.tail, tl=tl.tail) 3806 tl.tail = new harpoon.Temp.TempList(munchExp(el.head), null); 3807 } 3808 arglist = arglist.tail; 3809 3810 3811 HClass type; 3812 Label exlabel = new Label(); 3813 Label reglabel = new Label(); 3814 3815 if (ROOT.getRetval() == null) 3816 type = null; 3817 else 3818 type = code.getTreeDerivation().typeMap(ROOT.getRetval()); 3819 3820 // move the arguments into place 3821 emitCallPrologue(ROOT, arglist, handler, true); 3822 3823 // do the call 3824 emit (ROOT, "call "+func, 3825 new Temp[] { rego[0], rego[1] }, /* AAA - do better clobbers */ 3826 rego, /* AAA - do better uses */ 3827 new Label[] { exlabel }); 3828 emitDELAYSLOT (ROOT); 3829 3830 emitCallEpilogue(ROOT, retval, type); 3831 emitNoFall (ROOT, "ba "+reglabel, null, null, new Label[] { reglabel }); 3832 3833 /* Need handler stub to make sure retex is in right place */ 3834 emitLABEL (ROOT, exlabel+":", exlabel); 3835 emitHandlerStub (ROOT, retex, handler); 3836 3837 emitLABEL (ROOT, reglabel+":", reglabel); 3838 3839 /* Currently passing exceptional handler as first argument 3840 to get the backend up and running - andyb 3841 3842 // exceptional return handler 3843 emitLABEL (ROOT, elabel+":", elabel); 3844 emitHandlerStub(ROOT, retex, handler); 3845 3846 // normal return handler 3847 emitLABEL (ROOT, rlabel+":", rlabel); 3848 emitCallEpilogue(ROOT, retval, type); 3849 3850 // "fixup table" 3851 emitCallFixupTable (ROOT, rlabel, elabel); 3852 */ 3853 return; } 3854 } 3855 /* DATUM(CONST<i>(exp)) */ 3856 if (true 3857 // check statement type 3858 && stmArg instanceof harpoon.IR.Tree.DATUM 3859 && (true 3860 // check expression type 3861 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 3862 // check operand types 3863 && ( 3864 ( ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.INT && ! 3865 (((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.PreciselyTyped && 3866 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).isSmall())) || 3867 false ) 3868 // end check operand types 3869 ) 3870 ){ 3871 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 3872 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 3873 _matched_ = true; 3874 3875 if (_matched_) { // action code! : degree 2 3876 3877 3878 String lo = "0x" + Integer.toHexString(exp.intValue()); 3879 emitDIRECTIVE (ROOT, "\t.word " + lo + " ! " + exp); 3880 return; } 3881 } 3882 /* DATUM(CONST<l>(exp)) */ 3883 if (true 3884 // check statement type 3885 && stmArg instanceof harpoon.IR.Tree.DATUM 3886 && (true 3887 // check expression type 3888 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 3889 // check operand types 3890 && ( 3891 ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.LONG || 3892 false ) 3893 // end check operand types 3894 ) 3895 ){ 3896 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 3897 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 3898 _matched_ = true; 3899 3900 if (_matched_) { // action code! : degree 2 3901 3902 3903 long val = exp.longValue(); 3904 String lo = "0x" + Integer.toHexString((int) val); 3905 String hi = "0x" + Integer.toHexString((int) (val >> 32)); 3906 emitDIRECTIVE (ROOT, "\t.word " + hi + " ! " + exp); 3907 emitDIRECTIVE (ROOT, "\t.word " + lo + " ! " + exp); 3908 return; } 3909 } 3910 /* DATUM(CONST<u:8,s:8>(exp)) */ 3911 if (true 3912 // check statement type 3913 && stmArg instanceof harpoon.IR.Tree.DATUM 3914 && (true 3915 // check expression type 3916 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 3917 // check operand types 3918 && ( 3919 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).isSmall() && ( 3920 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).signed() ? ( 3921 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==8 || 3922 false) : ( 3923 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==8 || 3924 false) ) ) || 3925 false ) 3926 // end check operand types 3927 ) 3928 ){ 3929 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 3930 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 3931 _matched_ = true; 3932 3933 if (_matched_) { // action code! : degree 2 3934 3935 3936 String chardesc = (exp.intValue() >= 32 && exp.intValue() < 127 3937 && exp.intValue() != 96 /* backquotes */ 3938 && exp.intValue() != 34 /* double quotes */) ? 3939 ("\t! char "+((char)exp.intValue())) : ""; 3940 emitDIRECTIVE(ROOT, "\t.byte "+exp+chardesc); 3941 return; } 3942 } 3943 /* DATUM(CONST<u:16,s:16>(exp)) */ 3944 if (true 3945 // check statement type 3946 && stmArg instanceof harpoon.IR.Tree.DATUM 3947 && (true 3948 // check expression type 3949 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 3950 // check operand types 3951 && ( 3952 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).isSmall() && ( 3953 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).signed() ? ( 3954 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==16 || 3955 false) : ( 3956 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==16 || 3957 false) ) ) || 3958 false ) 3959 // end check operand types 3960 ) 3961 ){ 3962 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 3963 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 3964 _matched_ = true; 3965 3966 if (_matched_) { // action code! : degree 2 3967 3968 3969 String chardesc = (exp.intValue() >= 32 && exp.intValue() < 127 3970 && exp.intValue() != 96 /* backquotes */ 3971 && exp.intValue() != 34 /* double quotes */) ? 3972 ("\t! char "+((char)exp.intValue())) : ""; 3973 emitDIRECTIVE(ROOT, "\t.short "+exp+chardesc); 3974 return; } 3975 } 3976 /* DATUM(CONST<p>(exp)) */ 3977 if (true 3978 // check statement type 3979 && stmArg instanceof harpoon.IR.Tree.DATUM 3980 && (true 3981 // check expression type 3982 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 3983 // check operand types 3984 && ( 3985 ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.POINTER || 3986 false ) 3987 // end check operand types 3988 ) 3989 ){ 3990 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 3991 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 3992 _matched_ = true; 3993 3994 if (_matched_) { // action code! : degree 2 3995 3996 3997 emitDIRECTIVE(ROOT, "\t.word 0 ! should always be null pointer constant"); 3998 return; } 3999 } 4000 /* DATUM(CONST<l>(exp)) */ 4001 if (true 4002 // check statement type 4003 && stmArg instanceof harpoon.IR.Tree.DATUM 4004 && (true 4005 // check expression type 4006 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 4007 // check operand types 4008 && ( 4009 ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.LONG || 4010 false ) 4011 // end check operand types 4012 ) 4013 ){ 4014 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 4015 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 4016 _matched_ = true; 4017 4018 if (_matched_) { // action code! : degree 2 4019 4020 4021 long l = exp.longValue(); 4022 String lo = "0x" + Integer.toHexString((int)l); 4023 String hi = "0x" + Integer.toHexString((int)(l >> 32)); 4024 emitDIRECTIVE(ROOT, "\t.word " + hi + " ! hi (" + exp + ")"); 4025 emitDIRECTIVE(ROOT, "\t.word " + lo + " ! lo (" + exp + ")"); 4026 return; } 4027 } 4028 /* DATUM(NAME(l)) */ 4029 if (true 4030 // check statement type 4031 && stmArg instanceof harpoon.IR.Tree.DATUM 4032 && (true 4033 // check expression type 4034 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.NAME 4035 ) 4036 ){ 4037 harpoon.Temp.Label l = ((harpoon.IR.Tree.NAME)((harpoon.IR.Tree.DATUM)stmArg).getData()).label; 4038 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 4039 _matched_ = true; 4040 4041 if (_matched_) { // action code! : degree 2 4042 4043 4044 emitDIRECTIVE(ROOT, "\t.word " + l); 4045 return; } 4046 } 4047 /* JUMP(NAME(l)) */ 4048 if (true 4049 // check statement type 4050 && stmArg instanceof harpoon.IR.Tree.JUMP 4051 && (true 4052 // check expression type 4053 && ((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.NAME 4054 ) 4055 ){ 4056 harpoon.Temp.Label l = ((harpoon.IR.Tree.NAME)((harpoon.IR.Tree.JUMP)stmArg).getExp()).label; 4057 harpoon.IR.Tree.JUMP ROOT = (harpoon.IR.Tree.JUMP) stmArg; 4058 _matched_ = true; 4059 4060 if (_matched_) { // action code! : degree 2 4061 4062 4063 emitNoFall (ROOT, "ba " + l + "", null, null, new Label[] { l }); 4064 emitDELAYSLOT (ROOT); 4065 return; } 4066 } 4067 /* JUMP(BINOP<i,l,f,d,p>(ADD,e1,e2)) */ 4068 if (true 4069 // check statement type 4070 && stmArg instanceof harpoon.IR.Tree.JUMP 4071 && (true 4072 // check expression type 4073 && ((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.BINOP 4074 // check opcode 4075 && ((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).op == harpoon.IR.Tree.Bop.ADD 4076 // check operand types 4077 && ( 4078 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.DOUBLE || 4079 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.FLOAT || 4080 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.LONG || 4081 ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.POINTER || 4082 ( ((harpoon.IR.Tree.JUMP)stmArg).getExp().type() == Type.INT && ! 4083 (((harpoon.IR.Tree.JUMP)stmArg).getExp() instanceof harpoon.IR.Tree.PreciselyTyped && 4084 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.JUMP)stmArg).getExp()).isSmall())) || 4085 false ) 4086 // end check operand types 4087 // check left child 4088 // no check needed for ExpId children 4089 // check right child 4090 // no check needed for ExpId children 4091 ) 4092 ){ 4093 harpoon.IR.Tree.JUMP ROOT = (harpoon.IR.Tree.JUMP) stmArg; 4094 _matched_ = true; 4095 4096 if (_matched_) { // action code! : degree 2 4097 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getLeft()); 4098 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.BINOP)((harpoon.IR.Tree.JUMP)stmArg).getExp()).getRight()); 4099 4100 4101 List<Label> labelList = LabelList.toList (ROOT.targets); 4102 emitNoFall (ROOT, "jmpl `s0 + `s1, %g0", 4103 null, new Temp[] { e1, e2 }, labelList); 4104 emitDELAYSLOT (ROOT); 4105 return; } 4106 } 4107 /* MOVE<i,l,f,d,p>(MEM<i,l,f,d,p,u:8,u:16,s:8,s:16>(e1),e2) */ 4108 if (true 4109 // check statement type 4110 && stmArg instanceof harpoon.IR.Tree.MOVE 4111 // check operand types 4112 && ( 4113 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 4114 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 4115 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 4116 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 4117 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 4118 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 4119 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 4120 false ) 4121 // end check operand types 4122 && (true 4123 // no check needed for ExpId children 4124 ) 4125 && (true 4126 // check expression type 4127 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.MEM 4128 // check operand types 4129 && ( 4130 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 4131 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 4132 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 4133 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 4134 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 4135 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 4136 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 4137 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall() && ( 4138 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).signed() ? ( 4139 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 4140 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 4141 false) : ( 4142 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==8 || 4143 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).bitwidth()==16 || 4144 false) ) ) || 4145 false ) 4146 // end check operand types 4147 // check child 4148 // no check needed for ExpId children 4149 ) 4150 ){ 4151 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 4152 _matched_ = true; 4153 4154 if (_matched_) { // action code! : degree 2 4155 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 4156 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.MEM)((harpoon.IR.Tree.MOVE) stmArg).getDst()).getExp()); 4157 4158 4159 MEM dst = (MEM)(((MOVE)ROOT).getDst()); 4160 String suff = (dst.isDoubleWord()) ? "h" : ""; 4161 emitMEM (ROOT, "st"+storeSuffix(dst) + " `s1"+suff + ", [`s0]", 4162 null, new Temp[] { e1, e2 }); 4163 return; } 4164 } 4165 /* MOVE<i,p>(TEMP<i,l,f,d,p>(e1),e2) */ 4166 if (true 4167 // check statement type 4168 && stmArg instanceof harpoon.IR.Tree.MOVE 4169 // check operand types 4170 && ( 4171 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.POINTER || 4172 ( ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.INT && ! 4173 (((harpoon.IR.Tree.MOVE)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 4174 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE)stmArg)).isSmall())) || 4175 false ) 4176 // end check operand types 4177 && (true 4178 // no check needed for ExpId children 4179 ) 4180 && (true 4181 // check expression type 4182 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.TEMP 4183 // check operand types 4184 && ( 4185 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 4186 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 4187 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 4188 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 4189 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 4190 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 4191 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 4192 false ) 4193 // end check operand types 4194 ) 4195 ){ 4196 harpoon.Temp.Temp e1 = makeTemp((harpoon.IR.Tree.TEMP)((harpoon.IR.Tree.MOVE) stmArg).getDst(), inf.tempFactory()); 4197 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 4198 _matched_ = true; 4199 4200 if (_matched_) { // action code! : degree 2 4201 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 4202 4203 /* catch-all */ 4204 declare(e1, code.getTreeDerivation(), ROOT.getSrc()); 4205 emit (ROOT, "mov `s0, `d0", new Temp[] { e1 }, new Temp[] { e2 }); 4206 return; } 4207 } 4208 /* MOVE<l>(TEMP<i,l,f,d,p>(e1),e2) */ 4209 if (true 4210 // check statement type 4211 && stmArg instanceof harpoon.IR.Tree.MOVE 4212 // check operand types 4213 && ( 4214 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.LONG || 4215 false ) 4216 // end check operand types 4217 && (true 4218 // no check needed for ExpId children 4219 ) 4220 && (true 4221 // check expression type 4222 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.TEMP 4223 // check operand types 4224 && ( 4225 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 4226 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 4227 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 4228 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 4229 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 4230 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 4231 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 4232 false ) 4233 // end check operand types 4234 ) 4235 ){ 4236 harpoon.Temp.Temp e1 = makeTemp((harpoon.IR.Tree.TEMP)((harpoon.IR.Tree.MOVE) stmArg).getDst(), inf.tempFactory()); 4237 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 4238 _matched_ = true; 4239 4240 if (_matched_) { // action code! : degree 2 4241 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 4242 4243 /* long (pair of int) register move */ 4244 declare(e1, code.getTreeDerivation(), ROOT.getSrc()); 4245 emit (ROOT, "mov `s0l, `d0l", new Temp[] { e1 }, new Temp[] { e2 }); 4246 emit (ROOT, "mov `s0h, `d0h", new Temp[] { e1 }, new Temp[] { e2 }); 4247 return; } 4248 } 4249 /* MOVE<f>(TEMP<i,l,f,d,p>(e1),e2) */ 4250 if (true 4251 // check statement type 4252 && stmArg instanceof harpoon.IR.Tree.MOVE 4253 // check operand types 4254 && ( 4255 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.FLOAT || 4256 false ) 4257 // end check operand types 4258 && (true 4259 // no check needed for ExpId children 4260 ) 4261 && (true 4262 // check expression type 4263 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.TEMP 4264 // check operand types 4265 && ( 4266 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 4267 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 4268 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 4269 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 4270 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 4271 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 4272 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 4273 false ) 4274 // end check operand types 4275 ) 4276 ){ 4277 harpoon.Temp.Temp e1 = makeTemp((harpoon.IR.Tree.TEMP)((harpoon.IR.Tree.MOVE) stmArg).getDst(), inf.tempFactory()); 4278 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 4279 _matched_ = true; 4280 4281 if (_matched_) { // action code! : degree 2 4282 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 4283 4284 /* floating-point register move */ 4285 declare(e1, code.getTreeDerivation(), ROOT.getSrc()); 4286 emit(ROOT, "fmovs `s0, `d0", new Temp[] { e1 }, new Temp[] { e2 }); 4287 return; } 4288 } 4289 /* MOVE<d>(TEMP<i,l,f,d,p>(e1),e2) */ 4290 if (true 4291 // check statement type 4292 && stmArg instanceof harpoon.IR.Tree.MOVE 4293 // check operand types 4294 && ( 4295 ((harpoon.IR.Tree.MOVE)stmArg).type() == Type.DOUBLE || 4296 false ) 4297 // end check operand types 4298 && (true 4299 // no check needed for ExpId children 4300 ) 4301 && (true 4302 // check expression type 4303 && ((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.TEMP 4304 // check operand types 4305 && ( 4306 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.DOUBLE || 4307 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.FLOAT || 4308 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.LONG || 4309 ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.POINTER || 4310 ( ((harpoon.IR.Tree.MOVE) stmArg).getDst().type() == Type.INT && ! 4311 (((harpoon.IR.Tree.MOVE) stmArg).getDst() instanceof harpoon.IR.Tree.PreciselyTyped && 4312 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.MOVE) stmArg).getDst()).isSmall())) || 4313 false ) 4314 // end check operand types 4315 ) 4316 ){ 4317 harpoon.Temp.Temp e1 = makeTemp((harpoon.IR.Tree.TEMP)((harpoon.IR.Tree.MOVE) stmArg).getDst(), inf.tempFactory()); 4318 harpoon.IR.Tree.MOVE ROOT = (harpoon.IR.Tree.MOVE) stmArg; 4319 _matched_ = true; 4320 4321 if (_matched_) { // action code! : degree 2 4322 harpoon.Temp.Temp e2 = munchExp(((harpoon.IR.Tree.MOVE) stmArg).getSrc()); 4323 4324 /* double (pair of fp) register move */ 4325 declare(e1, code.getTreeDerivation(), ROOT.getSrc()); 4326 emit (ROOT, "fmovs `s0l, `d0l", new Temp[] { e1 }, new Temp[] { e2 }); 4327 emit (ROOT, "fmovs `s0h, `d0h", new Temp[] { e1 }, new Temp[] { e2 }); 4328 return; } 4329 } 4330 /* ALIGN(n) */ 4331 if (true 4332 // check statement type 4333 && stmArg instanceof harpoon.IR.Tree.ALIGN 4334 ){ 4335 int n = ((harpoon.IR.Tree.ALIGN)stmArg).alignment; harpoon.IR.Tree.ALIGN ROOT = (harpoon.IR.Tree.ALIGN) stmArg; 4336 _matched_ = true; 4337 4338 if (_matched_) { // action code! : degree 1 4339 4340 4341 emitDIRECTIVE( ROOT, "\t.align " + n); 4342 return; } 4343 } 4344 /* CALL(retval,retex,func,arglist,handler) */ 4345 if (true 4346 // check statement type 4347 && stmArg instanceof harpoon.IR.Tree.CALL 4348 && (true 4349 // no check needed for ExpId children 4350 ) 4351 ){ 4352 harpoon.Temp.Label handler = ((harpoon.IR.Tree.CALL)stmArg).getHandler().label; 4353 harpoon.IR.Tree.CALL ROOT = (harpoon.IR.Tree.CALL) stmArg; 4354 _matched_ = true&& ( !ROOT.isTailCall ); 4355 4356 if (_matched_) { // action code! : degree 1 4357 harpoon.Temp.Temp func = munchExp(((harpoon.IR.Tree.CALL) stmArg).getFunc()); 4358 harpoon.Temp.Temp retval = (((harpoon.IR.Tree.CALL)stmArg).getRetval()==null) ? null : munchExp(((harpoon.IR.Tree.CALL)stmArg).getRetval()); 4359 harpoon.Temp.Temp retex = munchExp(((harpoon.IR.Tree.CALL)stmArg).getRetex()); 4360 /* munch argument ExpList into a TempList */ 4361 harpoon.Temp.TempList arglist = new harpoon.Temp.TempList(null, null); 4362 { harpoon.Temp.TempList tl=arglist; 4363 for (harpoon.IR.Tree.ExpList el = ((harpoon.IR.Tree.CALL)stmArg).getArgs(); el!=null; el=el.tail, tl=tl.tail) 4364 tl.tail = new harpoon.Temp.TempList(munchExp(el.head), null); 4365 } 4366 arglist = arglist.tail; 4367 4368 4369 HClass type; 4370 Label exlabel = new Label(); 4371 Label reglabel = new Label(); 4372 4373 4374 if (ROOT.getRetval() == null) 4375 type = null; 4376 else 4377 type = code.getTreeDerivation().typeMap(ROOT.getRetval()); 4378 4379 // move the arguments into place 4380 emitCallPrologue(ROOT, arglist, handler, true); 4381 4382 // do the call 4383 emit (ROOT, "call `s0", 4384 new Temp[] { rego[0], rego[1] }, /* AAA - do better clobbers */ 4385 new Temp[] { func, rego[0], rego[1], rego[2], 4386 rego[3], rego[4], rego[5], rego[6], rego[7] }, 4387 /* AAA - need uses */ 4388 new Label[] { exlabel }); 4389 emitDELAYSLOT (ROOT); 4390 4391 emitCallEpilogue(ROOT, retval, type); 4392 emitNoFall (ROOT, "ba "+reglabel, null, null, new Label[] { reglabel }); 4393 4394 emitLABEL (ROOT, exlabel+":", exlabel); 4395 emitHandlerStub (ROOT, retex, handler); 4396 4397 emitLABEL (ROOT, reglabel+":", reglabel); 4398 4399 /* Using first parameter hack for handling exceptions 4400 4401 // exceptional return handler 4402 emitLABEL (ROOT, elabel+":", elabel); 4403 emitHandlerStub(ROOT, retex, handler); 4404 4405 // normal return handler 4406 emitLABEL (ROOT, rlabel+":", rlabel); 4407 emitCallEpilogue(ROOT, retval, type); 4408 4409 // "fixup table" 4410 emitCallFixupTable (ROOT, rlabel, elabel); 4411 */ 4412 return; } 4413 } 4414 /* CJUMP(e,true_label,false_label) */ 4415 if (true 4416 // check statement type 4417 && (stmArg instanceof harpoon.IR.Tree.CJUMP) 4418 && (true 4419 // no check needed for ExpId children 4420 ) 4421 ){ 4422 harpoon.Temp.Label false_label = ((harpoon.IR.Tree.CJUMP)stmArg).iffalse; 4423 harpoon.Temp.Label true_label = ((harpoon.IR.Tree.CJUMP)stmArg).iftrue; 4424 harpoon.IR.Tree.CJUMP ROOT = (harpoon.IR.Tree.CJUMP) stmArg; 4425 _matched_ = true; 4426 4427 if (_matched_) { // action code! : degree 1 4428 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.CJUMP) stmArg).getTest()); 4429 4430 4431 emitCC (ROOT, "cmp `s0, 0", null, new Temp[] { e }); 4432 emitCC (ROOT, "bne " + true_label + "", null, null, 4433 new Label[] { true_label }); 4434 emitDELAYSLOT (ROOT); 4435 4436 // should be able to optimize these away. 4437 emitCCNoFall (ROOT, "ba " + false_label + "", null, null, 4438 new Label[] { false_label }); 4439 emitDELAYSLOT (ROOT); 4440 return; } 4441 } 4442 /* EXPR(e1) */ 4443 if (true 4444 // check statement type 4445 && stmArg instanceof harpoon.IR.Tree.EXPR 4446 && (true 4447 // no check needed for ExpId children 4448 ) 4449 ){ 4450 harpoon.IR.Tree.EXPR ROOT = (harpoon.IR.Tree.EXPR) stmArg; 4451 _matched_ = true; 4452 4453 if (_matched_) { // action code! : degree 1 4454 harpoon.Temp.Temp e1 = munchExp(((harpoon.IR.Tree.EXPR)stmArg).getExp()); 4455 4456 4457 /* throw away temp e1 (not used) */ 4458 return; } 4459 } 4460 /* JUMP(e) */ 4461 if (true 4462 // check statement type 4463 && stmArg instanceof harpoon.IR.Tree.JUMP 4464 && (true 4465 // no check needed for ExpId children 4466 ) 4467 ){ 4468 harpoon.IR.Tree.JUMP ROOT = (harpoon.IR.Tree.JUMP) stmArg; 4469 _matched_ = true; 4470 4471 if (_matched_) { // action code! : degree 1 4472 harpoon.Temp.Temp e = munchExp(((harpoon.IR.Tree.JUMP)stmArg).getExp()); 4473 4474 4475 List<Label> labelList = LabelList.toList (ROOT.targets); 4476 emitNoFall (ROOT, "jmpl `s0, %g0", null, new Temp[] { e }, labelList); 4477 emitDELAYSLOT (ROOT); 4478 return; } 4479 } 4480 /* LABEL(l) */ 4481 if (true 4482 // check statement type 4483 && stmArg instanceof harpoon.IR.Tree.LABEL 4484 ){ 4485 String l = ((harpoon.IR.Tree.LABEL)stmArg).label.toString(); 4486 4487 harpoon.IR.Tree.LABEL ROOT = (harpoon.IR.Tree.LABEL) stmArg; 4488 _matched_ = true; 4489 4490 if (_matched_) { // action code! : degree 1 4491 4492 4493 emitLABEL (ROOT, l.toString()+":", ((LABEL) ROOT).label); 4494 return; } 4495 } 4496 /* METHOD(params) */ 4497 if (true 4498 // check statement type 4499 && stmArg instanceof harpoon.IR.Tree.METHOD 4500 ){ 4501 harpoon.IR.Tree.METHOD ROOT = (harpoon.IR.Tree.METHOD) stmArg; 4502 _matched_ = true; 4503 4504 if (_matched_) { // action code! : degree 1 4505 harpoon.Temp.Temp[] params = new harpoon.Temp.Temp[((harpoon.IR.Tree.METHOD)stmArg).getParamsLength()]; 4506 for (int _i_=0; _i_<params.length; _i_++) 4507 params[_i_] = munchExp(((harpoon.IR.Tree.METHOD)stmArg).getParams(_i_)); 4508 4509 4510 int loc = 0; 4511 emitENTRY(ROOT); 4512 4513 declare(SP, HClass.Void); 4514 // don't skip params[0], because we don't do any fancy stuff with it. 4515 for (int i = 0; i < params.length; i++) { 4516 declare(params[i], code.getTreeDerivation(), ROOT.getParams(i)); 4517 if (tb.isTwoWord(params[i])) { 4518 if (loc < 6) { // first half in register 4519 emit (ROOT, "mov `s0, `d0h", 4520 new Temp[] { params[i] }, 4521 new Temp[] { regi[loc] }); 4522 } else { // on stack 4523 emit (ROOT, "ld [`s0 + "+4*(loc-6)+92+"], `d0h", 4524 new Temp[] { params[i] }, 4525 new Temp[] { SP }); 4526 } 4527 loc++; 4528 if (loc < 6) { // second half in register 4529 emit (ROOT, "mov `s0, `d0l", 4530 new Temp[] { params[i] }, 4531 new Temp[] { regi[loc] }); 4532 } else { // on stack 4533 emit (ROOT, "ld [`s0 + "+4*(loc-6)+92+"], `d0l", 4534 new Temp[] { params[i] }, 4535 new Temp[] { SP }); 4536 } 4537 loc++; 4538 } else { 4539 if (loc < 6) { // in register 4540 assert params[i] != null; 4541 emit (ROOT, "mov `s0, `d0", 4542 new Temp[] { params[i] }, 4543 new Temp[] { regi[loc] }); 4544 } else { // on stack 4545 emitMEM (ROOT, "ld [`s0 + "+4*(loc-6)+92+"], `d0", 4546 new Temp[] { params[i] }, 4547 new Temp[] { SP }); 4548 } 4549 loc++; 4550 } 4551 } 4552 return; } 4553 } 4554 /* NATIVECALL(retval,func,arglist) */ 4555 if (true 4556 // check statement type 4557 && stmArg instanceof harpoon.IR.Tree.NATIVECALL 4558 && (true 4559 // no check needed for ExpId children 4560 ) 4561 ){ 4562 harpoon.IR.Tree.NATIVECALL ROOT = (harpoon.IR.Tree.NATIVECALL) stmArg; 4563 _matched_ = true; 4564 4565 if (_matched_) { // action code! : degree 1 4566 harpoon.Temp.Temp func = munchExp(((harpoon.IR.Tree.NATIVECALL) stmArg).getFunc()); 4567 harpoon.Temp.Temp retval = (((harpoon.IR.Tree.NATIVECALL)stmArg).getRetval()==null) ? null : munchExp(((harpoon.IR.Tree.NATIVECALL)stmArg).getRetval()); 4568 /* munch argument ExpList into a TempList */ 4569 harpoon.Temp.TempList arglist = new harpoon.Temp.TempList(null, null); 4570 { harpoon.Temp.TempList tl=arglist; 4571 for (harpoon.IR.Tree.ExpList el = ((harpoon.IR.Tree.NATIVECALL)stmArg).getArgs(); el!=null; el=el.tail, tl=tl.tail) 4572 tl.tail = new harpoon.Temp.TempList(munchExp(el.head), null); 4573 } 4574 arglist = arglist.tail; 4575 4576 4577 /* AAA need to make uses better */ 4578 HClass type; 4579 4580 if (ROOT.getRetval() == null) { 4581 type = null; 4582 } else { 4583 type = code.getTreeDerivation().typeMap(ROOT.getRetval()); 4584 } 4585 4586 emitCallPrologue (ROOT, arglist, null, false); 4587 4588 emit (ROOT, "call `s0", 4589 new Temp[] { rego[0] }, 4590 new Temp[] { func, rego[0], rego[1], rego[2], rego[3], rego[4], 4591 rego[5], rego[6], rego[7], rego[8] }); 4592 emitDELAYSLOT (ROOT); 4593 4594 emitCallEpilogue (ROOT, retval, type); 4595 return; } 4596 } 4597 /* RETURN<i,l,f,d,p>(val) */ 4598 if (true 4599 // check expression type 4600 && stmArg instanceof harpoon.IR.Tree.RETURN 4601 // check operand types 4602 && ( 4603 ((harpoon.IR.Tree.RETURN)stmArg).type() == Type.DOUBLE || 4604 ((harpoon.IR.Tree.RETURN)stmArg).type() == Type.FLOAT || 4605 ((harpoon.IR.Tree.RETURN)stmArg).type() == Type.LONG || 4606 ((harpoon.IR.Tree.RETURN)stmArg).type() == Type.POINTER || 4607 ( ((harpoon.IR.Tree.RETURN)stmArg).type() == Type.INT && ! 4608 (((harpoon.IR.Tree.RETURN)stmArg) instanceof harpoon.IR.Tree.PreciselyTyped && 4609 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.RETURN)stmArg)).isSmall())) || 4610 false ) 4611 // end check operand types 4612 && (true 4613 // no check needed for ExpId children 4614 ) 4615 ){ 4616 harpoon.IR.Tree.RETURN ROOT = (harpoon.IR.Tree.RETURN) stmArg; 4617 _matched_ = true; 4618 4619 if (_matched_) { // action code! : degree 1 4620 harpoon.Temp.Temp val = munchExp(((harpoon.IR.Tree.RETURN) stmArg).getRetval()); 4621 4622 4623 // Assume for now that this is non-leaf. 4624 // procFixup will need to change these to %o0 and %o1 if it is leaf... 4625 if (tb.isTwoWord(val)) { 4626 declare(regi[0], HClass.Void); 4627 declare(regi[1], HClass.Void); 4628 emit (ROOT, "mov `s0h, `d0", 4629 new Temp[] { regi[0] }, /* %i0 */ 4630 new Temp[] { val }); 4631 emit (ROOT, "mov `s0l, `d0", 4632 new Temp[] { regi[1] }, /* %i1 */ 4633 new Temp[] { val }); 4634 } else { 4635 declare(regi[0], code.getTreeDerivation(), ROOT.getRetval()); 4636 emit (ROOT, "mov `s0, `d0", 4637 new Temp[] { regi[0] }, /* %i0 */ 4638 new Temp[] { val }); 4639 } 4640 emitEXIT(ROOT); 4641 return; } 4642 } 4643 /* SEGMENT(CLASS) */ 4644 if (true 4645 // check statement type 4646 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4647 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.CLASS 4648 ){ 4649 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4650 _matched_ = true; 4651 4652 if (_matched_) { // action code! : degree 1 4653 4654 4655 emitDIRECTIVE(ROOT, "\t.data 1\t!.section class"); 4656 return; } 4657 } 4658 /* SEGMENT(CODE) */ 4659 if (true 4660 // check statement type 4661 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4662 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.CODE 4663 ){ 4664 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4665 _matched_ = true; 4666 4667 if (_matched_) { // action code! : degree 1 4668 4669 4670 emitDIRECTIVE(ROOT, "\t.text 0\t!.section code"); 4671 return; } 4672 } 4673 /* SEGMENT(GC) */ 4674 if (true 4675 // check statement type 4676 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4677 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.GC 4678 ){ 4679 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4680 _matched_ = true; 4681 4682 if (_matched_) { // action code! : degree 1 4683 4684 4685 emitDIRECTIVE(ROOT, "\t.data 2\t!.section gc"); 4686 return; } 4687 } 4688 /* SEGMENT(GC_INDEX) */ 4689 if (true 4690 // check statement type 4691 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4692 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.GC_INDEX 4693 ){ 4694 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4695 _matched_ = true; 4696 4697 if (_matched_) { // action code! : degree 1 4698 4699 4700 emitDIRECTIVE(ROOT, "\t.data 10\t!.section gc_index"); 4701 return; } 4702 } 4703 /* SEGMENT(INIT_DATA) */ 4704 if (true 4705 // check statement type 4706 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4707 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.INIT_DATA 4708 ){ 4709 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4710 _matched_ = true; 4711 4712 if (_matched_) { // action code! : degree 1 4713 4714 4715 emitDIRECTIVE(ROOT, "\t.data 3\t!.section init_data"); 4716 return; } 4717 } 4718 /* SEGMENT(STATIC_OBJECTS) */ 4719 if (true 4720 // check statement type 4721 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4722 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STATIC_OBJECTS 4723 ){ 4724 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4725 _matched_ = true; 4726 4727 if (_matched_) { // action code! : degree 1 4728 4729 4730 emitDIRECTIVE(ROOT, "\t.data 4\t!.section static_objects"); 4731 return; } 4732 } 4733 /* SEGMENT(STATIC_PRIMITIVES) */ 4734 if (true 4735 // check statement type 4736 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4737 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STATIC_PRIMITIVES 4738 ){ 4739 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4740 _matched_ = true; 4741 4742 if (_matched_) { // action code! : degree 1 4743 4744 4745 emitDIRECTIVE(ROOT, "\t.data 5\t!.section static_primitives"); 4746 return; } 4747 } 4748 /* SEGMENT(STRING_CONSTANTS) */ 4749 if (true 4750 // check statement type 4751 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4752 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STRING_CONSTANTS 4753 ){ 4754 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4755 _matched_ = true; 4756 4757 if (_matched_) { // action code! : degree 1 4758 4759 4760 emitDIRECTIVE(ROOT, "\t.data 6\t!.section string_constants"); 4761 return; } 4762 } 4763 /* SEGMENT(STRING_DATA) */ 4764 if (true 4765 // check statement type 4766 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4767 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STRING_DATA 4768 ){ 4769 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4770 _matched_ = true; 4771 4772 if (_matched_) { // action code! : degree 1 4773 4774 4775 emitDIRECTIVE(ROOT, "\t.data 7\t!.section string_data"); 4776 return; } 4777 } 4778 /* SEGMENT(REFLECTION_OBJECTS) */ 4779 if (true 4780 // check statement type 4781 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4782 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.REFLECTION_OBJECTS 4783 ){ 4784 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4785 _matched_ = true; 4786 4787 if (_matched_) { // action code! : degree 1 4788 4789 4790 emitDIRECTIVE(ROOT, "\t.data 8\t!.section reflection_objects"); 4791 return; } 4792 } 4793 /* SEGMENT(REFLECTION_DATA) */ 4794 if (true 4795 // check statement type 4796 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4797 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.REFLECTION_DATA 4798 ){ 4799 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4800 _matched_ = true; 4801 4802 if (_matched_) { // action code! : degree 1 4803 4804 4805 emitDIRECTIVE(ROOT, "\t.data 9\t!.section reflection_data"); 4806 return; } 4807 } 4808 /* SEGMENT(TEXT) */ 4809 if (true 4810 // check statement type 4811 && stmArg instanceof harpoon.IR.Tree.SEGMENT 4812 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.TEXT 4813 ){ 4814 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 4815 _matched_ = true; 4816 4817 if (_matched_) { // action code! : degree 1 4818 4819 4820 emitDIRECTIVE(ROOT, "\t.text \t!.section text"); 4821 return; } 4822 } 4823 /* THROW(val,handler) */ 4824 if (true 4825 // check expression type 4826 && stmArg instanceof harpoon.IR.Tree.THROW 4827 && (true 4828 // no check needed for ExpId children 4829 ) 4830 && (true 4831 // no check needed for ExpId children 4832 ) 4833 ){ 4834 harpoon.IR.Tree.THROW ROOT = (harpoon.IR.Tree.THROW) stmArg; 4835 _matched_ = true; 4836 4837 if (_matched_) { // action code! : degree 1 4838 harpoon.Temp.Temp val = munchExp(((harpoon.IR.Tree.THROW) stmArg).getRetex()); 4839 harpoon.Temp.Temp handler = munchExp(((harpoon.IR.Tree.THROW) stmArg).getHandler()); 4840 4841 4842 // like the StrongARM backend, the exception handling is done 4843 // by the caller. we just have to make sure that we return to 4844 // the right place so that the caller knows to use the exception handler. 4845 4846 // again, assume non-leaf for now - might have to change registers 4847 // in procFixup if we determine that it is a leaf procedure and 4848 // optimize for that 4849 4850 // move exception value into correct registers 4851 if (tb.isTwoWord(val)) { 4852 declare(regi[0], HClass.Void); 4853 declare(regi[1], HClass.Void); 4854 emit (ROOT, "mov `s0h, `d0", 4855 new Temp[] { regi[0] }, 4856 new Temp[] { val }); 4857 emit (ROOT, "mov `s0l, `d0", 4858 new Temp[] { regi[1] }, 4859 new Temp[] { val }); 4860 } else { 4861 declare(regi[0], code.getTreeDerivation(), ROOT.getRetex()); 4862 emit (ROOT, "mov `s0, `d0", new Temp[] { regi[0] }, new Temp[] { val }); 4863 } 4864 4865 declare(regi[7], HClass.Void); 4866 // replace %i7 with the handler passed in %i0 4867 emit (ROOT, "mov `s0, `d0", new Temp[] { regi[7] }, new Temp[] { regi[0] }); 4868 // retr returns to %i7 + 8, so subtract 8 to get to the right place 4869 emit (ROOT, "sub `s0, 8, `d0", 4870 new Temp[] { regi[7] }, 4871 new Temp[] { regi[7] }); 4872 /* 4873 // The point of lookup is to set %i7 to the correct value for the 4874 // returning jump 4875 emit (ROOT, "call _lookup", 4876 new Temp[] { regi[7] }, 4877 new Temp[] { }); 4878 */ 4879 emitEXIT (ROOT); 4880 return; } 4881 } 4882 assert _matched_ : "Uh oh...\nmaximal munch didn't match anything...SPEC file\nis not complete enough for this program\nDied on "+prettyPrint(stmArg)+" in " + prettyPrint(globalStmArg); 4883 } // end munchStm 4884 public void visit(harpoon.IR.Tree.Tree treee){ 4885 assert false : "Should never visit generic harpoon.IR.Tree.Treein CggVisitor"; 4886 } // end visit(harpoon.IR.Tree.Tree) 4887 public void visit(harpoon.IR.Tree.Stm treee){ 4888 debug("munching "+treee+" "); 4889 munchStm(treee); 4890 } // end visit(harpoon.IR.Tree.Stm) 4891 public void visit(harpoon.IR.Tree.SEQ treee){ 4892 treee.getLeft().accept(this); 4893 treee.getRight().accept(this); 4894 } 4895 } 4896 CggVisitor visitor = new CggVisitor(); 4897 harpoon.IR.Tree.Tree t = (harpoon.IR.Tree.Tree) code.getRootElement(); 4898 t.accept(visitor); 4899 clearDecl(); // reset temp type mappings 4900 4901 // What to execute at the end of the instruction 4902 // selection method 4903 4904 assert first != null : "Should always generate some instrs"; 4905 return net.cscott.jutil.Default.pair(first, getDerivation()); 4906 } 4907 /** Generates assembly code from a <code>harpoon.IR.Tree.Data</code>. 4908 <BR> <B>modifies:</B> <code>this</code> 4909 <BR> <B>effects:</B> 4910 Scans <code>tree</code> to define a layout of 4911 Instructions, calling auxillary methods 4912 and data structures as defined in the .Spec file 4913 @param tree Set of abstract <code>Tree</code> instructions 4914 that form the body of the data structure being compiled. 4915 */ 4916 public final harpoon.IR.Assem.Instr cgg_genData(harpoon.IR.Tree.Data code, final harpoon.IR.Assem.InstrFactory inf) { 4917 _methodPrologue_(inf); 4918 4919 // State Variables which are initialized each 4920 // time we do instruction selection on another 4921 // bit of TreeCode 4922 4923 this.instrFactory = inf; 4924 codeGenTempMap = new HashMap(); 4925 4926 final class CggVisitor extends harpoon.IR.Tree.TreeVisitor { 4927 harpoon.Temp.Temp munchExp(harpoon.IR.Tree.Exp expArg) { 4928 boolean _matched_ = false; 4929 clearDecl(); // reset temp type mappings 4930 assert false : "Uh oh...\nmaximal munch didn't match anything...SPEC file\nis not complete enough for this program\nDied on "+prettyPrint(expArg)+" in " + prettyPrint(globalStmArg); 4931 return null; // doesn't matter, we're dead if we didn't match... 4932 } // end munchExp 4933 harpoon.IR.Tree.Stm globalStmArg=null; 4934 void munchStm(harpoon.IR.Tree.Stm stmArg) { 4935 globalStmArg = stmArg; 4936 boolean _matched_ = false; 4937 clearDecl(); // reset temp type mappings 4938 /* DATUM(CONST<i>(exp)) */ 4939 if (true 4940 // check statement type 4941 && stmArg instanceof harpoon.IR.Tree.DATUM 4942 && (true 4943 // check expression type 4944 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 4945 // check operand types 4946 && ( 4947 ( ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.INT && ! 4948 (((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.PreciselyTyped && 4949 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).isSmall())) || 4950 false ) 4951 // end check operand types 4952 ) 4953 ){ 4954 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 4955 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 4956 _matched_ = true; 4957 4958 if (_matched_) { // action code! : degree 2 4959 4960 4961 String lo = "0x" + Integer.toHexString(exp.intValue()); 4962 emitDIRECTIVE (ROOT, "\t.word " + lo + " ! " + exp); 4963 return; } 4964 } 4965 /* DATUM(CONST<l>(exp)) */ 4966 if (true 4967 // check statement type 4968 && stmArg instanceof harpoon.IR.Tree.DATUM 4969 && (true 4970 // check expression type 4971 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 4972 // check operand types 4973 && ( 4974 ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.LONG || 4975 false ) 4976 // end check operand types 4977 ) 4978 ){ 4979 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 4980 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 4981 _matched_ = true; 4982 4983 if (_matched_) { // action code! : degree 2 4984 4985 4986 long val = exp.longValue(); 4987 String lo = "0x" + Integer.toHexString((int) val); 4988 String hi = "0x" + Integer.toHexString((int) (val >> 32)); 4989 emitDIRECTIVE (ROOT, "\t.word " + hi + " ! " + exp); 4990 emitDIRECTIVE (ROOT, "\t.word " + lo + " ! " + exp); 4991 return; } 4992 } 4993 /* DATUM(CONST<u:8,s:8>(exp)) */ 4994 if (true 4995 // check statement type 4996 && stmArg instanceof harpoon.IR.Tree.DATUM 4997 && (true 4998 // check expression type 4999 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 5000 // check operand types 5001 && ( 5002 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).isSmall() && ( 5003 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).signed() ? ( 5004 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==8 || 5005 false) : ( 5006 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==8 || 5007 false) ) ) || 5008 false ) 5009 // end check operand types 5010 ) 5011 ){ 5012 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 5013 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 5014 _matched_ = true; 5015 5016 if (_matched_) { // action code! : degree 2 5017 5018 5019 String chardesc = (exp.intValue() >= 32 && exp.intValue() < 127 5020 && exp.intValue() != 96 /* backquotes */ 5021 && exp.intValue() != 34 /* double quotes */) ? 5022 ("\t! char "+((char)exp.intValue())) : ""; 5023 emitDIRECTIVE(ROOT, "\t.byte "+exp+chardesc); 5024 return; } 5025 } 5026 /* DATUM(CONST<u:16,s:16>(exp)) */ 5027 if (true 5028 // check statement type 5029 && stmArg instanceof harpoon.IR.Tree.DATUM 5030 && (true 5031 // check expression type 5032 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 5033 // check operand types 5034 && ( 5035 (((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).isSmall() && ( 5036 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).signed() ? ( 5037 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==16 || 5038 false) : ( 5039 ((harpoon.IR.Tree.PreciselyTyped)((harpoon.IR.Tree.DATUM)stmArg).getData()).bitwidth()==16 || 5040 false) ) ) || 5041 false ) 5042 // end check operand types 5043 ) 5044 ){ 5045 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 5046 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 5047 _matched_ = true; 5048 5049 if (_matched_) { // action code! : degree 2 5050 5051 5052 String chardesc = (exp.intValue() >= 32 && exp.intValue() < 127 5053 && exp.intValue() != 96 /* backquotes */ 5054 && exp.intValue() != 34 /* double quotes */) ? 5055 ("\t! char "+((char)exp.intValue())) : ""; 5056 emitDIRECTIVE(ROOT, "\t.short "+exp+chardesc); 5057 return; } 5058 } 5059 /* DATUM(CONST<p>(exp)) */ 5060 if (true 5061 // check statement type 5062 && stmArg instanceof harpoon.IR.Tree.DATUM 5063 && (true 5064 // check expression type 5065 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 5066 // check operand types 5067 && ( 5068 ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.POINTER || 5069 false ) 5070 // end check operand types 5071 ) 5072 ){ 5073 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 5074 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 5075 _matched_ = true; 5076 5077 if (_matched_) { // action code! : degree 2 5078 5079 5080 emitDIRECTIVE(ROOT, "\t.word 0 ! should always be null pointer constant"); 5081 return; } 5082 } 5083 /* DATUM(CONST<l>(exp)) */ 5084 if (true 5085 // check statement type 5086 && stmArg instanceof harpoon.IR.Tree.DATUM 5087 && (true 5088 // check expression type 5089 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.CONST 5090 // check operand types 5091 && ( 5092 ((harpoon.IR.Tree.DATUM)stmArg).getData().type() == Type.LONG || 5093 false ) 5094 // end check operand types 5095 ) 5096 ){ 5097 Number exp = ((harpoon.IR.Tree.CONST) ((harpoon.IR.Tree.DATUM)stmArg).getData()).value; 5098 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 5099 _matched_ = true; 5100 5101 if (_matched_) { // action code! : degree 2 5102 5103 5104 long l = exp.longValue(); 5105 String lo = "0x" + Integer.toHexString((int)l); 5106 String hi = "0x" + Integer.toHexString((int)(l >> 32)); 5107 emitDIRECTIVE(ROOT, "\t.word " + hi + " ! hi (" + exp + ")"); 5108 emitDIRECTIVE(ROOT, "\t.word " + lo + " ! lo (" + exp + ")"); 5109 return; } 5110 } 5111 /* DATUM(NAME(l)) */ 5112 if (true 5113 // check statement type 5114 && stmArg instanceof harpoon.IR.Tree.DATUM 5115 && (true 5116 // check expression type 5117 && ((harpoon.IR.Tree.DATUM)stmArg).getData() instanceof harpoon.IR.Tree.NAME 5118 ) 5119 ){ 5120 harpoon.Temp.Label l = ((harpoon.IR.Tree.NAME)((harpoon.IR.Tree.DATUM)stmArg).getData()).label; 5121 harpoon.IR.Tree.DATUM ROOT = (harpoon.IR.Tree.DATUM) stmArg; 5122 _matched_ = true; 5123 5124 if (_matched_) { // action code! : degree 2 5125 5126 5127 emitDIRECTIVE(ROOT, "\t.word " + l); 5128 return; } 5129 } 5130 /* ALIGN(n) */ 5131 if (true 5132 // check statement type 5133 && stmArg instanceof harpoon.IR.Tree.ALIGN 5134 ){ 5135 int n = ((harpoon.IR.Tree.ALIGN)stmArg).alignment; harpoon.IR.Tree.ALIGN ROOT = (harpoon.IR.Tree.ALIGN) stmArg; 5136 _matched_ = true; 5137 5138 if (_matched_) { // action code! : degree 1 5139 5140 5141 emitDIRECTIVE( ROOT, "\t.align " + n); 5142 return; } 5143 } 5144 /* LABEL(l) */ 5145 if (true 5146 // check statement type 5147 && stmArg instanceof harpoon.IR.Tree.LABEL 5148 ){ 5149 String l = ((harpoon.IR.Tree.LABEL)stmArg).label.toString(); 5150 5151 harpoon.IR.Tree.LABEL ROOT = (harpoon.IR.Tree.LABEL) stmArg; 5152 _matched_ = true; 5153 5154 if (_matched_) { // action code! : degree 1 5155 5156 5157 emitLABEL (ROOT, l.toString()+":", ((LABEL) ROOT).label); 5158 return; } 5159 } 5160 /* SEGMENT(CLASS) */ 5161 if (true 5162 // check statement type 5163 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5164 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.CLASS 5165 ){ 5166 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5167 _matched_ = true; 5168 5169 if (_matched_) { // action code! : degree 1 5170 5171 5172 emitDIRECTIVE(ROOT, "\t.data 1\t!.section class"); 5173 return; } 5174 } 5175 /* SEGMENT(CODE) */ 5176 if (true 5177 // check statement type 5178 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5179 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.CODE 5180 ){ 5181 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5182 _matched_ = true; 5183 5184 if (_matched_) { // action code! : degree 1 5185 5186 5187 emitDIRECTIVE(ROOT, "\t.text 0\t!.section code"); 5188 return; } 5189 } 5190 /* SEGMENT(GC) */ 5191 if (true 5192 // check statement type 5193 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5194 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.GC 5195 ){ 5196 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5197 _matched_ = true; 5198 5199 if (_matched_) { // action code! : degree 1 5200 5201 5202 emitDIRECTIVE(ROOT, "\t.data 2\t!.section gc"); 5203 return; } 5204 } 5205 /* SEGMENT(GC_INDEX) */ 5206 if (true 5207 // check statement type 5208 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5209 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.GC_INDEX 5210 ){ 5211 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5212 _matched_ = true; 5213 5214 if (_matched_) { // action code! : degree 1 5215 5216 5217 emitDIRECTIVE(ROOT, "\t.data 10\t!.section gc_index"); 5218 return; } 5219 } 5220 /* SEGMENT(INIT_DATA) */ 5221 if (true 5222 // check statement type 5223 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5224 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.INIT_DATA 5225 ){ 5226 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5227 _matched_ = true; 5228 5229 if (_matched_) { // action code! : degree 1 5230 5231 5232 emitDIRECTIVE(ROOT, "\t.data 3\t!.section init_data"); 5233 return; } 5234 } 5235 /* SEGMENT(STATIC_OBJECTS) */ 5236 if (true 5237 // check statement type 5238 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5239 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STATIC_OBJECTS 5240 ){ 5241 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5242 _matched_ = true; 5243 5244 if (_matched_) { // action code! : degree 1 5245 5246 5247 emitDIRECTIVE(ROOT, "\t.data 4\t!.section static_objects"); 5248 return; } 5249 } 5250 /* SEGMENT(STATIC_PRIMITIVES) */ 5251 if (true 5252 // check statement type 5253 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5254 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STATIC_PRIMITIVES 5255 ){ 5256 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5257 _matched_ = true; 5258 5259 if (_matched_) { // action code! : degree 1 5260 5261 5262 emitDIRECTIVE(ROOT, "\t.data 5\t!.section static_primitives"); 5263 return; } 5264 } 5265 /* SEGMENT(STRING_CONSTANTS) */ 5266 if (true 5267 // check statement type 5268 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5269 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STRING_CONSTANTS 5270 ){ 5271 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5272 _matched_ = true; 5273 5274 if (_matched_) { // action code! : degree 1 5275 5276 5277 emitDIRECTIVE(ROOT, "\t.data 6\t!.section string_constants"); 5278 return; } 5279 } 5280 /* SEGMENT(STRING_DATA) */ 5281 if (true 5282 // check statement type 5283 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5284 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.STRING_DATA 5285 ){ 5286 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5287 _matched_ = true; 5288 5289 if (_matched_) { // action code! : degree 1 5290 5291 5292 emitDIRECTIVE(ROOT, "\t.data 7\t!.section string_data"); 5293 return; } 5294 } 5295 /* SEGMENT(REFLECTION_OBJECTS) */ 5296 if (true 5297 // check statement type 5298 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5299 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.REFLECTION_OBJECTS 5300 ){ 5301 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5302 _matched_ = true; 5303 5304 if (_matched_) { // action code! : degree 1 5305 5306 5307 emitDIRECTIVE(ROOT, "\t.data 8\t!.section reflection_objects"); 5308 return; } 5309 } 5310 /* SEGMENT(REFLECTION_DATA) */ 5311 if (true 5312 // check statement type 5313 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5314 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.REFLECTION_DATA 5315 ){ 5316 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5317 _matched_ = true; 5318 5319 if (_matched_) { // action code! : degree 1 5320 5321 5322 emitDIRECTIVE(ROOT, "\t.data 9\t!.section reflection_data"); 5323 return; } 5324 } 5325 /* SEGMENT(TEXT) */ 5326 if (true 5327 // check statement type 5328 && stmArg instanceof harpoon.IR.Tree.SEGMENT 5329 && ((harpoon.IR.Tree.SEGMENT)stmArg).segtype == harpoon.IR.Tree.SEGMENT.TEXT 5330 ){ 5331 harpoon.IR.Tree.SEGMENT ROOT = (harpoon.IR.Tree.SEGMENT) stmArg; 5332 _matched_ = true; 5333 5334 if (_matched_) { // action code! : degree 1 5335 5336 5337 emitDIRECTIVE(ROOT, "\t.text \t!.section text"); 5338 return; } 5339 } 5340 assert _matched_ : "Uh oh...\nmaximal munch didn't match anything...SPEC file\nis not complete enough for this program\nDied on "+prettyPrint(stmArg)+" in " + prettyPrint(globalStmArg); 5341 } // end munchStm 5342 public void visit(harpoon.IR.Tree.Tree treee){ 5343 assert false : "Should never visit generic harpoon.IR.Tree.Treein CggVisitor"; 5344 } // end visit(harpoon.IR.Tree.Tree) 5345 public void visit(harpoon.IR.Tree.Stm treee){ 5346 debug("munching "+treee+" "); 5347 munchStm(treee); 5348 } // end visit(harpoon.IR.Tree.Stm) 5349 public void visit(harpoon.IR.Tree.SEQ treee){ 5350 treee.getLeft().accept(this); 5351 treee.getRight().accept(this); 5352 } 5353 } 5354 CggVisitor visitor = new CggVisitor(); 5355 harpoon.IR.Tree.Tree t = (harpoon.IR.Tree.Tree) code.getRootElement(); 5356 t.accept(visitor); 5357 clearDecl(); // reset temp type mappings 5358 5359 // What to execute at the end of the instruction 5360 // selection method 5361 5362 assert first != null : "Should always generate some instrs"; 5363 return first; 5364 } 5365 }