GPUOcelot
|
00001 00007 #ifndef IL_INSTRUCTION_H_INCLUDED 00008 #define IL_INSTRUCTION_H_INCLUDED 00009 00010 // Ocelot includes 00011 #include <ocelot/ir/interface/Instruction.h> 00012 #include <ocelot/ir/interface/ILOperand.h> 00013 00014 namespace ir 00015 { 00017 class ILInstruction : public Instruction 00018 { 00019 public: 00021 enum Opcode 00022 { 00023 Abs, 00024 Add, 00025 And, 00026 Break, 00027 Cmov_Logical, 00028 Cos_Vec, 00029 Div, 00030 Else, 00031 End, 00032 EndIf, 00033 EndLoop, 00034 Eq, 00035 Exp_Vec, 00036 Ffb_Hi, 00037 Fence, 00038 Fma, 00039 FtoI, 00040 FtoU, 00041 Ge, 00042 Iadd, 00043 Iand, 00044 Ieq, 00045 IfLogicalNZ, 00046 IfLogicalZ, 00047 Ige, 00048 Ilt, 00049 Imax, 00050 Imin, 00051 Imul, 00052 Ine, 00053 Inegate, 00054 Inot, 00055 Ior, 00056 Ishl, 00057 Ishr, 00058 ItoF, 00059 Ixor, 00060 Lds_And_Resource, 00061 Lds_Load_Id, 00062 Lds_Or_Resource, 00063 Lds_Read_Add_Resource, 00064 Lds_Store_Id, 00065 Log_Vec, 00066 Lt, 00067 Mad, 00068 Mov, 00069 Mul, 00070 Ne, 00071 Rcp, 00072 Round_Nearest, 00073 Round_Neginf, 00074 Rsq_Vec, 00075 Sin_Vec, 00076 Sub, 00077 Sqrt_Vec, 00078 Uav_Arena_Load_Id, 00079 Uav_Arena_Store_Id, 00080 Uav_Raw_Load_Id, 00081 Uav_Raw_Store_Id, 00082 Uav_Read_Add_Id, 00083 Uav_Read_Max_Id, 00084 Uav_Read_Min_Id, 00085 Uav_Read_Xchg_Id, 00086 Udiv, 00087 Umul, 00088 Umul24, 00089 Ushr, 00090 UtoF, 00091 WhileLoop, 00092 InvalidOpcode 00093 }; 00094 00095 enum DataType 00096 { 00097 Byte, 00098 Short, 00099 Dword 00100 }; 00101 00102 enum ClampOperation 00103 { 00104 Clamp, 00105 NoClamp 00106 }; 00107 00108 enum ShiftScale 00109 { 00110 Shift_D2, // shift value right by 1 bit 00111 Shift_D4, // shift value right by 2 bits 00112 Shift_D8, // shift value right by 3 bits 00113 Shift_None, 00114 Shift_X2, // shift value left by 1 bit 00115 Shift_X4, // shift value left by 2 bits 00116 Shift_X8, // shift value left by 3 bits 00117 }; 00118 00119 public: 00121 ILInstruction(Opcode op = InvalidOpcode); 00122 00123 /*****************************/ 00127 static std::string toString(Opcode o); 00128 static std::string toString(DataType d); 00129 static std::string toString(const ClampOperation &c); 00130 static std::string toString(const ShiftScale &s); 00131 virtual std::string toString() const; 00133 00135 virtual Instruction* clone(bool copy=true) const = 0; 00136 00138 virtual std::string valid() const; 00139 00140 public: 00142 const Opcode opcode; 00143 00145 ClampOperation clamp; 00146 00148 ShiftScale shift_scale; 00149 }; 00150 00152 class ILUnaryInstruction : public ILInstruction 00153 { 00154 public: 00156 ILUnaryInstruction(Opcode op = InvalidOpcode); 00157 00159 virtual std::string toString() const; 00160 00162 virtual Instruction* clone(bool copy = true) const = 0; 00163 00164 public: 00166 ILOperand d; 00167 00169 ILOperand a; 00170 }; 00171 00173 class ILBinaryInstruction : public ILInstruction 00174 { 00175 public: 00177 ILBinaryInstruction(Opcode op = InvalidOpcode); 00178 00180 virtual std::string toString() const; 00181 00183 virtual Instruction* clone(bool copy=true) const = 0; 00184 00185 public: 00187 ILOperand d; 00188 00190 ILOperand a; 00191 00193 ILOperand b; 00194 }; 00195 00197 class ILTrinaryInstruction : public ILInstruction 00198 { 00199 public: 00201 ILTrinaryInstruction(Opcode op = InvalidOpcode); 00202 00204 virtual std::string toString() const; 00205 00207 virtual Instruction* clone(bool copy=true) const = 0; 00208 00209 public: 00211 ILOperand d; 00212 00214 ILOperand a; 00215 00217 ILOperand b; 00218 00220 ILOperand c; 00221 }; 00222 00223 class ILAbs: public ILUnaryInstruction 00224 { 00225 public: 00226 ILAbs(); 00227 Instruction *clone(bool copy=true) const; 00228 }; 00229 00230 class ILAdd : public ILBinaryInstruction 00231 { 00232 public: 00233 ILAdd(); 00234 Instruction *clone(bool copy=true) const; 00235 }; 00236 00237 class ILAnd : public ILBinaryInstruction 00238 { 00239 public: 00240 ILAnd(); 00241 Instruction *clone(bool copy=true) const; 00242 }; 00243 00244 class ILBreak: public ILInstruction 00245 { 00246 public: 00247 ILBreak(); 00248 Instruction *clone(bool copy=true) const; 00249 }; 00250 00251 class ILCmov_Logical : public ILTrinaryInstruction 00252 { 00253 public: 00254 ILCmov_Logical(); 00255 Instruction *clone(bool copy=true) const; 00256 }; 00257 00258 class ILCos_Vec : public ILUnaryInstruction 00259 { 00260 public: 00261 ILCos_Vec(); 00262 Instruction *clone(bool copy=true) const; 00263 }; 00264 00265 class ILDiv : public ILBinaryInstruction 00266 { 00267 public: 00268 ILDiv(); 00269 Instruction *clone(bool copy=true) const; 00270 }; 00271 00272 class ILElse : public ILInstruction 00273 { 00274 public: 00275 ILElse(); 00276 Instruction *clone(bool copy=true) const; 00277 }; 00278 00279 class ILEnd : public ILInstruction 00280 { 00281 public: 00282 ILEnd(); 00283 Instruction *clone(bool copy=true) const; 00284 }; 00285 00286 class ILEndIf : public ILInstruction 00287 { 00288 public: 00289 ILEndIf(); 00290 Instruction *clone(bool copy=true) const; 00291 }; 00292 00293 class ILEndLoop : public ILInstruction 00294 { 00295 public: 00296 ILEndLoop(); 00297 Instruction *clone(bool copy=true) const; 00298 }; 00299 00300 class ILEq : public ILBinaryInstruction 00301 { 00302 public: 00303 ILEq(); 00304 Instruction *clone(bool copy=true) const; 00305 }; 00306 00307 class ILExp_Vec: public ILUnaryInstruction 00308 { 00309 public: 00310 ILExp_Vec(); 00311 Instruction *clone(bool copy=true) const; 00312 }; 00313 00314 class ILFfb_Hi: public ILUnaryInstruction 00315 { 00316 public: 00317 ILFfb_Hi(); 00318 Instruction *clone(bool copy=true) const; 00319 }; 00320 00321 class ILFence: public ILInstruction 00322 { 00323 public: 00324 ILFence(); 00325 Instruction *clone(bool copy=true) const; 00326 00328 void threads(bool value = true); 00329 00331 void lds(bool value = true); 00332 00334 void memory(bool value = true); 00335 00337 std::string toString() const; 00338 00339 private: 00341 bool _threads, _lds, _memory; 00342 }; 00343 00344 class ILFma : public ILTrinaryInstruction 00345 { 00346 public: 00347 ILFma(); 00348 Instruction *clone(bool copy=true) const; 00349 }; 00350 00351 class ILFtoI: public ILUnaryInstruction 00352 { 00353 public: 00354 ILFtoI(); 00355 Instruction *clone(bool copy=true) const; 00356 }; 00357 00358 class ILFtoU: public ILUnaryInstruction 00359 { 00360 public: 00361 ILFtoU(); 00362 Instruction *clone(bool copy=true) const; 00363 }; 00364 00365 class ILGe : public ILBinaryInstruction 00366 { 00367 public: 00368 ILGe(); 00369 Instruction *clone(bool copy=true) const; 00370 }; 00371 00372 class ILIadd : public ILBinaryInstruction 00373 { 00374 public: 00375 ILIadd(); 00376 Instruction *clone(bool copy=true) const; 00377 }; 00378 00379 class ILIand : public ILBinaryInstruction 00380 { 00381 public: 00382 ILIand(); 00383 Instruction *clone(bool copy=true) const; 00384 }; 00385 00386 class ILIeq : public ILBinaryInstruction 00387 { 00388 public: 00389 ILIeq(); 00390 Instruction *clone(bool copy=true) const; 00391 }; 00392 00393 class ILIfLogicalNZ : public ILInstruction 00394 { 00395 public: 00396 ILIfLogicalNZ(); 00397 Instruction *clone(bool copy=true) const; 00398 00400 ILOperand a; 00401 00403 std::string toString() const; 00404 }; 00405 00406 class ILIfLogicalZ : public ILInstruction 00407 { 00408 public: 00409 ILIfLogicalZ(); 00410 Instruction *clone(bool copy=true) const; 00411 00413 ILOperand a; 00414 00416 std::string toString() const; 00417 }; 00418 00419 class ILIge : public ILBinaryInstruction 00420 { 00421 public: 00422 ILIge(); 00423 Instruction *clone(bool copy=true) const; 00424 }; 00425 00426 class ILIlt : public ILBinaryInstruction 00427 { 00428 public: 00429 ILIlt(); 00430 Instruction *clone(bool copy=true) const; 00431 }; 00432 00433 class ILImax : public ILBinaryInstruction 00434 { 00435 public: 00436 ILImax(); 00437 Instruction *clone(bool copy=true) const; 00438 }; 00439 00440 class ILImin : public ILBinaryInstruction 00441 { 00442 public: 00443 ILImin(); 00444 Instruction *clone(bool copy=true) const; 00445 }; 00446 00447 class ILImul : public ILBinaryInstruction 00448 { 00449 public: 00450 ILImul(); 00451 Instruction *clone(bool copy=true) const; 00452 }; 00453 00454 class ILIne : public ILBinaryInstruction 00455 { 00456 public: 00457 ILIne(); 00458 Instruction *clone(bool copy=true) const; 00459 }; 00460 00461 class ILInegate : public ILUnaryInstruction 00462 { 00463 public: 00464 ILInegate(); 00465 Instruction *clone(bool copy=true) const; 00466 }; 00467 00468 class ILInot : public ILUnaryInstruction 00469 { 00470 public: 00471 ILInot(); 00472 Instruction *clone(bool copy=true) const; 00473 }; 00474 00475 class ILIor : public ILBinaryInstruction 00476 { 00477 public: 00478 ILIor(); 00479 Instruction *clone(bool copy=true) const; 00480 }; 00481 00482 class ILIshl : public ILBinaryInstruction 00483 { 00484 public: 00485 ILIshl(); 00486 Instruction *clone(bool copy=true) const; 00487 }; 00488 00489 class ILIshr : public ILBinaryInstruction 00490 { 00491 public: 00492 ILIshr(); 00493 Instruction *clone(bool copy=true) const; 00494 }; 00495 00496 class ILItoF: public ILUnaryInstruction 00497 { 00498 public: 00499 ILItoF(); 00500 Instruction *clone(bool copy=true) const; 00501 }; 00502 00503 class ILIxor : public ILBinaryInstruction 00504 { 00505 public: 00506 ILIxor(); 00507 Instruction *clone(bool copy=true) const; 00508 }; 00509 00510 class ILLds_And_Resource : public ILUnaryInstruction 00511 { 00512 public: 00513 ILLds_And_Resource(); 00514 Instruction *clone(bool copy=true) const; 00515 }; 00516 00517 class ILLds_Load_Id : public ILUnaryInstruction 00518 { 00519 public: 00520 ILLds_Load_Id(); 00521 Instruction *clone(bool copy=true) const; 00522 }; 00523 00524 class ILLds_Or_Resource : public ILUnaryInstruction 00525 { 00526 public: 00527 ILLds_Or_Resource(); 00528 Instruction *clone(bool copy=true) const; 00529 }; 00530 00531 class ILLds_Read_Add_Resource : public ILBinaryInstruction 00532 { 00533 public: 00534 ILLds_Read_Add_Resource(); 00535 Instruction *clone(bool copy=true) const; 00536 }; 00537 00538 class ILLds_Store_Id : public ILUnaryInstruction 00539 { 00540 public: 00541 ILLds_Store_Id(); 00542 Instruction *clone(bool copy=true) const; 00543 }; 00544 00545 class ILLog_Vec : public ILUnaryInstruction 00546 { 00547 public: 00548 ILLog_Vec(); 00549 Instruction *clone(bool copy=true) const; 00550 }; 00551 00552 class ILLt : public ILBinaryInstruction 00553 { 00554 public: 00555 ILLt(); 00556 Instruction *clone(bool copy=true) const; 00557 }; 00558 00559 class ILMad : public ILTrinaryInstruction 00560 { 00561 public: 00562 ILMad(); 00563 Instruction *clone(bool copy=true) const; 00564 }; 00565 00566 class ILMov : public ILUnaryInstruction 00567 { 00568 public: 00569 ILMov(); 00570 Instruction *clone(bool copy=true) const; 00571 }; 00572 00573 class ILMul : public ILBinaryInstruction 00574 { 00575 public: 00576 ILMul(); 00577 Instruction *clone(bool copy=true) const; 00578 }; 00579 00580 class ILNe : public ILBinaryInstruction 00581 { 00582 public: 00583 ILNe(); 00584 Instruction *clone(bool copy=true) const; 00585 }; 00586 00587 class ILRcp : public ILUnaryInstruction 00588 { 00589 public: 00590 ILRcp(); 00591 Instruction *clone(bool copy=true) const; 00592 }; 00593 00594 class ILRound_Nearest : public ILUnaryInstruction 00595 { 00596 public: 00597 ILRound_Nearest(); 00598 Instruction *clone(bool copy=true) const; 00599 }; 00600 00601 class ILRound_Neginf: public ILUnaryInstruction 00602 { 00603 public: 00604 ILRound_Neginf(); 00605 Instruction *clone(bool copy=true) const; 00606 }; 00607 00608 class ILRsq_Vec : public ILUnaryInstruction 00609 { 00610 public: 00611 ILRsq_Vec(); 00612 Instruction *clone(bool copy=true) const; 00613 }; 00614 00615 class ILSin_Vec : public ILUnaryInstruction 00616 { 00617 public: 00618 ILSin_Vec(); 00619 Instruction *clone(bool copy=true) const; 00620 }; 00621 00622 class ILSub : public ILBinaryInstruction 00623 { 00624 public: 00625 ILSub(); 00626 Instruction *clone(bool copy=true) const; 00627 }; 00628 00629 class ILSqrt_Vec: public ILUnaryInstruction 00630 { 00631 public: 00632 ILSqrt_Vec(); 00633 Instruction *clone(bool copy=true) const; 00634 }; 00635 00636 class ILUav_Arena_Load_Id : public ILUnaryInstruction 00637 { 00638 public: 00639 ILUav_Arena_Load_Id(); 00640 Instruction *clone(bool copy=true) const; 00641 00643 std::string toString() const; 00644 00645 public: 00646 DataType type; 00647 }; 00648 00649 class ILUav_Arena_Store_Id : public ILUnaryInstruction 00650 { 00651 public: 00652 ILUav_Arena_Store_Id(); 00653 Instruction *clone(bool copy=true) const; 00654 00656 std::string toString() const; 00657 00658 public: 00659 DataType type; 00660 }; 00661 00662 class ILUav_Raw_Load_Id : public ILUnaryInstruction 00663 { 00664 public: 00665 ILUav_Raw_Load_Id(); 00666 Instruction *clone(bool copy=true) const; 00667 }; 00668 00669 class ILUav_Raw_Store_Id : public ILUnaryInstruction 00670 { 00671 public: 00672 ILUav_Raw_Store_Id(); 00673 Instruction *clone(bool copy=true) const; 00674 }; 00675 00676 class ILUav_Read_Add_Id : public ILBinaryInstruction 00677 { 00678 public: 00679 ILUav_Read_Add_Id(); 00680 Instruction *clone(bool copy=true) const; 00681 }; 00682 00683 class ILUav_Read_Max_Id : public ILBinaryInstruction 00684 { 00685 public: 00686 ILUav_Read_Max_Id(); 00687 Instruction *clone(bool copy=true) const; 00688 }; 00689 00690 class ILUav_Read_Min_Id : public ILBinaryInstruction 00691 { 00692 public: 00693 ILUav_Read_Min_Id(); 00694 Instruction *clone(bool copy=true) const; 00695 }; 00696 00697 class ILUav_Read_Xchg_Id : public ILBinaryInstruction 00698 { 00699 public: 00700 ILUav_Read_Xchg_Id(); 00701 Instruction *clone(bool copy=true) const; 00702 }; 00703 00704 class ILUdiv : public ILBinaryInstruction 00705 { 00706 public: 00707 ILUdiv(); 00708 Instruction *clone(bool copy=true) const; 00709 }; 00710 00711 class ILUmul : public ILBinaryInstruction 00712 { 00713 public: 00714 ILUmul(); 00715 Instruction *clone(bool copy=true) const; 00716 }; 00717 00718 class ILUmul24 : public ILBinaryInstruction 00719 { 00720 public: 00721 ILUmul24(); 00722 Instruction *clone(bool copy=true) const; 00723 }; 00724 00725 class ILUshr : public ILBinaryInstruction 00726 { 00727 public: 00728 ILUshr(); 00729 Instruction *clone(bool copy=true) const; 00730 }; 00731 00732 class ILUtoF: public ILUnaryInstruction 00733 { 00734 public: 00735 ILUtoF(); 00736 Instruction *clone(bool copy=true) const; 00737 }; 00738 00739 class ILWhileLoop : public ILInstruction 00740 { 00741 public: 00742 ILWhileLoop(); 00743 Instruction *clone(bool copy=true) const; 00744 }; 00745 } 00746 #endif