real_het

big case

Mar 27th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 8.83 KB | None | 0 0
  1.       //encode
  2.       handled:=false;
  3.       case ir.enc of
  4.         SOP1:if(ir.pfmt='s0, s0')or(ir.pfmt='s[0:1], s[0:1]')or(ir.pfmt='s0, s[0:1]')then begin
  5.             emitcode(s7(0)shl 16+sk8(1));
  6.           end else if(ir.pfmt='s0')then begin //s_cbranch_join
  7.             emitcode(sk8(0));
  8.           end else if(ir.pfmt='s[0:1]')then begin //s_setpc, s_getpc
  9.             emitcode(s7(0)+s7(0)shl 16);
  10.           end;
  11.         SOP2:if(ir.pfmt='s0, s0, s0')or(ir.pfmt='s[0:1], s[0:1], s[0:1]')or(ir.pfmt='s[0:1], s[0:1], s0') then begin
  12.             emitcode(s7(0)shl 16+sk8(1)+sk8(2)shl 8);
  13.           end;
  14.         SOPK:if(ir.pfmt='s0, 0x0000')or(ir.pfmt='s0, hwreg(0, 0, 1)'{s_getreg})then begin
  15.             emitcode(s7(0)shl 16+simm16(1)and $FFFF)
  16.           end else if ir.pfmt='hwreg(0, 0, 1), s0' then begin //s_setreg
  17.             emitcode(s7(1)shl 16+simm16(0)and $FFFF)
  18.           end else if ir.pfmt='s[0:1], label_0027'then begin //s_cbranch_fork
  19.             AddLabel_RelativeRef_beforeEmit(paramStr(1));
  20.             emitcode(s7(0)shl 16)
  21.           end;
  22.         SOPC:if ir.pfmt='s0, s0' then begin
  23.             emitcode(sk8(0)+sk8(1)shl 8);
  24.           end;
  25.         SMRD:if ir.pfmt='s[0:1]'then begin
  26.             emitcode(s7(0)shl 15);//s_memtime
  27.           end else if{ir.pfmt='s[0:1], s[0:3], s0'}true{same params for all}then begin
  28.             emitcode(s7(0)shl 15+s7(1)shl 8+sk9(2));
  29.           end;
  30.         SOPP:if ir.pfmt='0x0000' then begin
  31.             emitcode(simm16(0));
  32.           end else if ir.pfmt='' then begin
  33.             emitcode(0);
  34.           end else if ir.pfmt='label' then begin
  35.             AddLabel_RelativeRef_beforeEmit(paramStr(0));
  36.             emitcode(0);
  37.           end;
  38.         VOP1:if ir.pfmt='v0, s0' then begin
  39.             emitcode(v8(0)shl 17+svk9(1))
  40.           end else if ir.pfmt='s0, s0' then begin
  41.             emitcode(s7(0)shl 17+(v8(1)+$100))//v_readfirstlane
  42.           end;
  43.         VOP2:if ir.pfmt='v0, s0, v0' then begin
  44.             emitcode(v8(0)shl 17+svk9(1)+v8(2)shl 9)
  45.           end else if(ir.pfmt='v0, vcc, s0, v0')or(ir.pfmt='v0, vcc, s0, v0, vcc')then begin
  46.             emitcode(v8(0)shl 17+svk9(2)+v8(3)shl 9)
  47.           end else if ir.pfmt='s0, s0, s0' then begin
  48.             emitcode(s8(0)shl 17+(v8(1)+$100)+sk8(2)shl 9)//v_readlane
  49.           end else if ir.pfmt='v0, s0, s0' then begin
  50.             emitcode(v8(0)shl 17+(sk8(1))+sk8(2)shl 9)//v_writelane
  51.           end;
  52.         VOP3:if(ir.pfmt='v0, s0, s0, s0')or(ir.pfmt='v0, s0, s0, s[0:1]')then begin
  53.             emitcode(v8(0)                              +VOP3Mods0(1,3));
  54.             emit(svk9(1)+svk9(2)shl 9+svk9(3)shl 18     +VOP3Mods1(1,3));
  55.           end else if(ir.pfmt='v0, s0, s0')or(ir.pfmt='v0, s0, s0 vop3')then begin
  56.             emitcode(v8(0)                              +VOP3Mods0(1,2));
  57.             emit(svk9(1)                                +VOP3Mods1(1,2)
  58.                 +svk9(2)shl 9
  59.                 +switch(IsWild2('v_mul*32',ir.name),$2000000));//mul-nal az scr2 parameter valamiert 2 (a calcl-altal), de megy ugy is, ha 0
  60.           end else if(ir.pfmt='v0, s[0:1], s0, s0')then begin
  61.             emitcode(v8(0)+s7(1)shl 8); if VOP3Mods0(2,2)<>0 then error('No abs()/Clamp allowed when dst S reg is specified');
  62.             emit(svk9(2)                                +VOP3Mods1(2,2)
  63.                 +svk9(3)shl 9);
  64.           end else if(ir.pfmt='v0, s[0:1], s0, s0, s[0:1]')then begin
  65.             emitcode(v8(0)+s7(1)shl 8); if VOP3Mods0(2,2)<>0 then error('No abs()/Clamp allowed when dst S reg is specified');
  66.             emit(svk9(2)                                +VOP3Mods1(2,2)
  67.                 +svk9(3)shl 9+ s7(4)shl 18);
  68.           end else if ir.pfmt='s[0:1], s0, s0' then begin
  69.             emitcode(s8(0)                              +VOP3Mods0(1,2));
  70.             emit(svk9(1)+svk9(2)shl 9                   +VOP3Mods1(1,2));
  71.           end else if ir.pfmt='v0, s0 vop3' then begin
  72.             emitcode(v8(0)                              +VOP3Mods0(1,2));
  73.             emit(svk9(1)                                +VOP3Mods1(1,2));
  74.           end;
  75.         VOPC:if ir.pfmt='vcc, s0, v0' then begin
  76.             emitCode(svk9(1)+v8(2)shl 9);
  77.           end;
  78.         DS:if(ir.pfmt='v0, v0, v2')then begin  //az offset az valojaban 2 offset (lo,hi)
  79.             emitcode(OptionInt('offset0',0,$FF)
  80.                   or OptionInt('offset1',0,$FF)shl 8
  81.                   or OptionBit('gds')shl 17);
  82.             emit(v8(1)  +v8(2)shl 8  +v8(0)shl 24);
  83.           end else if(ir.pfmt='v0, v[2:3], v[0:1]')or(ir.pfmt='v0, v2, v0')then begin  //ds_writex2_b??
  84.             emitcode(OptionInt('offset0',0,$FF)
  85.                   or OptionInt('offset1',0,$FF)shl 8
  86.                   or OptionBit('gds')shl 17);
  87. //            emit(v8(1)  +v8(2)shl 8  +v8(0)shl 24);
  88.              emit(v8(0)  +v8(1)shl 8  +v8(2)shl 16)
  89.           end else if ir.pfmt='v0, v2'then begin
  90.             emitcode(OptionInt('offset',0,$FFFF)
  91.                     +OptionBit('gds')shl 17);
  92.             emit(v8(0)  +v8(1)shl 8);
  93.           end else if ir.pfmt='v0, v[2:3]'then begin //_b64
  94.             emitcode(OptionInt('offset',0,$FFFF)
  95.                     +OptionBit('gds')shl 17);
  96.             emit(v8(0)  +v8(1)shl 8);
  97.           end else if ir.pfmt='v0, v0'{masmilyen paramlista}then begin
  98.             emitcode(OptionInt('offset',0,$FFFF)
  99.                     +OptionBit('gds')shl 17);
  100.             emit(v8(1)  +v8(0)shl 24);
  101.           end else if ir.pfmt='v[0:1], v0' then begin //x2, _b64
  102.             emitcode({OptionInt('offset',0,$FFFF)
  103.                   or }OptionInt('offset0',0,$FF)
  104.                   or OptionInt('offset1',0,$FF)shl 8
  105.                   or OptionBit('gds')shl 17);
  106.             emit(v8(1)  +v8(0)shl 24);
  107.           end;
  108.  
  109.         MTBUF:if{v0, v0, s[0:3], s0 format:[BUF_DATA_FORMAT_INVALID]}true{same params for all} then begin
  110.             emitcode(optionInt('offset',0,$FFF){12bit}
  111.                     +optionBit('offen')shl 12
  112.                     +optionBit('idxen')shl 13
  113.                     +optionBit('glc')shl 14
  114.                     +optionBit('adr64')shl 15
  115.                     +optionDFmt('format')shl 19
  116.                     +optionNFmt('format')shl 23);
  117.             emit(v8(1)+
  118.                  v8(0)shl 8+
  119.                  s7(2)shr 2 shl 16+
  120.                  sk8(3)shl 24+
  121.                  optionBit('slc')shl 22+  //bit21: unknown
  122.                  optionBit('tfe')shl 23);
  123.             if immeds<>nil then error('imm32 not allowed in MTBUF');
  124.           end;
  125.         MUBUF:if ir.pfmt='v0, v0, s[0:3], s0' then begin
  126.             emitcode(optionInt('offset') {12bit}
  127.                     +optionBit('offen')shl 12
  128.                     +optionBit('idxen')shl 13
  129.                     +optionBit('glc')shl 14
  130.                     +optionBit('adr64')shl 15
  131.                     +optionBit('lds')shl 16
  132.                     +optionBit('ls')shl 17);
  133.             emit(v8(1)+
  134.                  v8(0)shl 8+
  135.                  s7(2)shr 2 shl 16+
  136.                  sk8(3)shl 24+
  137.                  optionBit('slc')shl 22+  //bit21: unknown
  138.                  optionBit('tfe')shl 23);
  139.             if immeds<>nil then error('imm32 not allowed in MUBUF');
  140.           end;
  141.         XOP:begin
  142.           handled:=true;
  143.           if line.instr='isa79xx' then//nothing yet
  144.           else if line.instr='numvgprs'then AOptions.numvgprs:=paramConst(0)
  145.           else if line.instr='numsgprs'then AOptions.numsgprs:=paramConst(0)
  146.           else if line.instr='cb0size'then AOptions.cb0sizeDQWords:=paramConst(0)
  147.           else if line.instr='ldssize'then AOptions.ldsSizeBytes:=paramConst(0)
  148.           else if line.instr='dd' then for i:=0 to paramCount-1 do emit(paramConst(i))
  149.           else if line.instr='alias' then for i:=0 to paramCount-1 do Aliases.DeclareAlias(paramStr(i))
  150.           else if line.instr='v_temp_range' then Aliases.DeclareTempRange(regV,line.params)
  151.           else if line.instr='s_temp_range' then Aliases.DeclareTempRange(regS,line.params)
  152.           else if line.instr='v_temp' then begin j:=OptionInt('align',1,32,1); for i:=0 to paramCount-1 do Aliases.DeclareTemp(regV,paramStr(i),j)end
  153.           else if line.instr='s_temp' then begin j:=OptionInt('align',1,32,1); for i:=0 to paramCount-1 do Aliases.DeclareTemp(regS,paramStr(i),j)end
  154.           else if line.instr='enter' then Aliases.EnterTempScope
  155.           else if line.instr='leave' then Aliases.LeaveTempScope
  156.           else if line.instr='eof' then emit(0)
  157.           else if line.instr='numthreadpergroup'then with AOptions.NumThreadPerGroup do begin
  158.             x:=paramConst(0);
  159.             if paramCount>1 then y:=paramConst(1) else y:=1;
  160.             if paramCount>2 then z:=paramConst(2) else z:=1;
  161.           end else if line.instr='oclbuffers'then with AOptions.OclBuffers do begin
  162.             uavCount:=paramConst(0);
  163.             cbCount:=paramConst(1);
  164.           end else handled:=false;
  165.         end
  166.       end;
Advertisement
Add Comment
Please, Sign In to add comment