Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //encode
- handled:=false;
- case ir.enc of
- SOP1:if(ir.pfmt='s0, s0')or(ir.pfmt='s[0:1], s[0:1]')or(ir.pfmt='s0, s[0:1]')then begin
- emitcode(s7(0)shl 16+sk8(1));
- end else if(ir.pfmt='s0')then begin //s_cbranch_join
- emitcode(sk8(0));
- end else if(ir.pfmt='s[0:1]')then begin //s_setpc, s_getpc
- emitcode(s7(0)+s7(0)shl 16);
- end;
- 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
- emitcode(s7(0)shl 16+sk8(1)+sk8(2)shl 8);
- end;
- SOPK:if(ir.pfmt='s0, 0x0000')or(ir.pfmt='s0, hwreg(0, 0, 1)'{s_getreg})then begin
- emitcode(s7(0)shl 16+simm16(1)and $FFFF)
- end else if ir.pfmt='hwreg(0, 0, 1), s0' then begin //s_setreg
- emitcode(s7(1)shl 16+simm16(0)and $FFFF)
- end else if ir.pfmt='s[0:1], label_0027'then begin //s_cbranch_fork
- AddLabel_RelativeRef_beforeEmit(paramStr(1));
- emitcode(s7(0)shl 16)
- end;
- SOPC:if ir.pfmt='s0, s0' then begin
- emitcode(sk8(0)+sk8(1)shl 8);
- end;
- SMRD:if ir.pfmt='s[0:1]'then begin
- emitcode(s7(0)shl 15);//s_memtime
- end else if{ir.pfmt='s[0:1], s[0:3], s0'}true{same params for all}then begin
- emitcode(s7(0)shl 15+s7(1)shl 8+sk9(2));
- end;
- SOPP:if ir.pfmt='0x0000' then begin
- emitcode(simm16(0));
- end else if ir.pfmt='' then begin
- emitcode(0);
- end else if ir.pfmt='label' then begin
- AddLabel_RelativeRef_beforeEmit(paramStr(0));
- emitcode(0);
- end;
- VOP1:if ir.pfmt='v0, s0' then begin
- emitcode(v8(0)shl 17+svk9(1))
- end else if ir.pfmt='s0, s0' then begin
- emitcode(s7(0)shl 17+(v8(1)+$100))//v_readfirstlane
- end;
- VOP2:if ir.pfmt='v0, s0, v0' then begin
- emitcode(v8(0)shl 17+svk9(1)+v8(2)shl 9)
- end else if(ir.pfmt='v0, vcc, s0, v0')or(ir.pfmt='v0, vcc, s0, v0, vcc')then begin
- emitcode(v8(0)shl 17+svk9(2)+v8(3)shl 9)
- end else if ir.pfmt='s0, s0, s0' then begin
- emitcode(s8(0)shl 17+(v8(1)+$100)+sk8(2)shl 9)//v_readlane
- end else if ir.pfmt='v0, s0, s0' then begin
- emitcode(v8(0)shl 17+(sk8(1))+sk8(2)shl 9)//v_writelane
- end;
- VOP3:if(ir.pfmt='v0, s0, s0, s0')or(ir.pfmt='v0, s0, s0, s[0:1]')then begin
- emitcode(v8(0) +VOP3Mods0(1,3));
- emit(svk9(1)+svk9(2)shl 9+svk9(3)shl 18 +VOP3Mods1(1,3));
- end else if(ir.pfmt='v0, s0, s0')or(ir.pfmt='v0, s0, s0 vop3')then begin
- emitcode(v8(0) +VOP3Mods0(1,2));
- emit(svk9(1) +VOP3Mods1(1,2)
- +svk9(2)shl 9
- +switch(IsWild2('v_mul*32',ir.name),$2000000));//mul-nal az scr2 parameter valamiert 2 (a calcl-altal), de megy ugy is, ha 0
- end else if(ir.pfmt='v0, s[0:1], s0, s0')then begin
- emitcode(v8(0)+s7(1)shl 8); if VOP3Mods0(2,2)<>0 then error('No abs()/Clamp allowed when dst S reg is specified');
- emit(svk9(2) +VOP3Mods1(2,2)
- +svk9(3)shl 9);
- end else if(ir.pfmt='v0, s[0:1], s0, s0, s[0:1]')then begin
- emitcode(v8(0)+s7(1)shl 8); if VOP3Mods0(2,2)<>0 then error('No abs()/Clamp allowed when dst S reg is specified');
- emit(svk9(2) +VOP3Mods1(2,2)
- +svk9(3)shl 9+ s7(4)shl 18);
- end else if ir.pfmt='s[0:1], s0, s0' then begin
- emitcode(s8(0) +VOP3Mods0(1,2));
- emit(svk9(1)+svk9(2)shl 9 +VOP3Mods1(1,2));
- end else if ir.pfmt='v0, s0 vop3' then begin
- emitcode(v8(0) +VOP3Mods0(1,2));
- emit(svk9(1) +VOP3Mods1(1,2));
- end;
- VOPC:if ir.pfmt='vcc, s0, v0' then begin
- emitCode(svk9(1)+v8(2)shl 9);
- end;
- DS:if(ir.pfmt='v0, v0, v2')then begin //az offset az valojaban 2 offset (lo,hi)
- emitcode(OptionInt('offset0',0,$FF)
- or OptionInt('offset1',0,$FF)shl 8
- or OptionBit('gds')shl 17);
- emit(v8(1) +v8(2)shl 8 +v8(0)shl 24);
- end else if(ir.pfmt='v0, v[2:3], v[0:1]')or(ir.pfmt='v0, v2, v0')then begin //ds_writex2_b??
- emitcode(OptionInt('offset0',0,$FF)
- or OptionInt('offset1',0,$FF)shl 8
- or OptionBit('gds')shl 17);
- // emit(v8(1) +v8(2)shl 8 +v8(0)shl 24);
- emit(v8(0) +v8(1)shl 8 +v8(2)shl 16)
- end else if ir.pfmt='v0, v2'then begin
- emitcode(OptionInt('offset',0,$FFFF)
- +OptionBit('gds')shl 17);
- emit(v8(0) +v8(1)shl 8);
- end else if ir.pfmt='v0, v[2:3]'then begin //_b64
- emitcode(OptionInt('offset',0,$FFFF)
- +OptionBit('gds')shl 17);
- emit(v8(0) +v8(1)shl 8);
- end else if ir.pfmt='v0, v0'{masmilyen paramlista}then begin
- emitcode(OptionInt('offset',0,$FFFF)
- +OptionBit('gds')shl 17);
- emit(v8(1) +v8(0)shl 24);
- end else if ir.pfmt='v[0:1], v0' then begin //x2, _b64
- emitcode({OptionInt('offset',0,$FFFF)
- or }OptionInt('offset0',0,$FF)
- or OptionInt('offset1',0,$FF)shl 8
- or OptionBit('gds')shl 17);
- emit(v8(1) +v8(0)shl 24);
- end;
- MTBUF:if{v0, v0, s[0:3], s0 format:[BUF_DATA_FORMAT_INVALID]}true{same params for all} then begin
- emitcode(optionInt('offset',0,$FFF){12bit}
- +optionBit('offen')shl 12
- +optionBit('idxen')shl 13
- +optionBit('glc')shl 14
- +optionBit('adr64')shl 15
- +optionDFmt('format')shl 19
- +optionNFmt('format')shl 23);
- emit(v8(1)+
- v8(0)shl 8+
- s7(2)shr 2 shl 16+
- sk8(3)shl 24+
- optionBit('slc')shl 22+ //bit21: unknown
- optionBit('tfe')shl 23);
- if immeds<>nil then error('imm32 not allowed in MTBUF');
- end;
- MUBUF:if ir.pfmt='v0, v0, s[0:3], s0' then begin
- emitcode(optionInt('offset') {12bit}
- +optionBit('offen')shl 12
- +optionBit('idxen')shl 13
- +optionBit('glc')shl 14
- +optionBit('adr64')shl 15
- +optionBit('lds')shl 16
- +optionBit('ls')shl 17);
- emit(v8(1)+
- v8(0)shl 8+
- s7(2)shr 2 shl 16+
- sk8(3)shl 24+
- optionBit('slc')shl 22+ //bit21: unknown
- optionBit('tfe')shl 23);
- if immeds<>nil then error('imm32 not allowed in MUBUF');
- end;
- XOP:begin
- handled:=true;
- if line.instr='isa79xx' then//nothing yet
- else if line.instr='numvgprs'then AOptions.numvgprs:=paramConst(0)
- else if line.instr='numsgprs'then AOptions.numsgprs:=paramConst(0)
- else if line.instr='cb0size'then AOptions.cb0sizeDQWords:=paramConst(0)
- else if line.instr='ldssize'then AOptions.ldsSizeBytes:=paramConst(0)
- else if line.instr='dd' then for i:=0 to paramCount-1 do emit(paramConst(i))
- else if line.instr='alias' then for i:=0 to paramCount-1 do Aliases.DeclareAlias(paramStr(i))
- else if line.instr='v_temp_range' then Aliases.DeclareTempRange(regV,line.params)
- else if line.instr='s_temp_range' then Aliases.DeclareTempRange(regS,line.params)
- 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
- 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
- else if line.instr='enter' then Aliases.EnterTempScope
- else if line.instr='leave' then Aliases.LeaveTempScope
- else if line.instr='eof' then emit(0)
- else if line.instr='numthreadpergroup'then with AOptions.NumThreadPerGroup do begin
- x:=paramConst(0);
- if paramCount>1 then y:=paramConst(1) else y:=1;
- if paramCount>2 then z:=paramConst(2) else z:=1;
- end else if line.instr='oclbuffers'then with AOptions.OclBuffers do begin
- uavCount:=paramConst(0);
- cbCount:=paramConst(1);
- end else handled:=false;
- end
- end;
Advertisement
Add Comment
Please, Sign In to add comment