VEC-C 进阶 指令解析及寻址模式

来源:互联网 发布:如何用淘宝内部券赚钱 编辑:程序博客网 时间:2024/05/16 15:12
1,逻辑移位与算术移位:logicshift不考虑符号,空位用0补,arithmaticshift要保证符号不变。
2,vec-c中数据类型转换只能是显式的:
char16 c;
short16 s = c; //not allowed
short16 s = (short16)c; //allowed

ushort16 u;
uchar16 c = vcast(satu,u);
3,要把vec-c中的type+数字型的类型看作是一个很长的变量,比如short16 in;就表示16X2X8bit长的一个变量。
要赋值给它,当然是与给short变量赋值是一个道理了。
例 
short16 inN;
short in[16]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
inN=*(short16*)in;

uint8 t = (uint8)0x00020000;
short16 v2 = (short16)t;

3,从内存中加载数据到vector寄存器,可以直接用地址初始化:
例   注意这里千万别写错成short16 v0=(short16)*(short*)p_u8Src;
uchar* p_u8Src;
short16 v0=(short16)*(uchar16*)p_u8Src;
或者用vpld:
    short16 inN;
    short in[16]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
    inN=*(short16*)in;
    short16 v0=(short16)vpld(in,inN);

4,将向量输出到内存中去用vst:
    short p_out_u8[16];
    vst(v0,(short*)p_out_u8,(short)0xffff);

5,矢量的裁剪与组合
short32 vec;
short16 vec_lo = vunpack_lo(vec);
short16 vec_hi = vunpack_hi(vec);

short16 vec_lo;
short16 vec_hi;
short32 vec = vpack(vec_lo,vec_hi);
6,Vselect   
int8 v1, v2, v3;
unsigned char vpr0;
v3 = vselect(v1, v2, vpr0);
For every ith element of v3, if the ith bit of vpr0 is set, it will contain the ith element of v1, otherwise it will contain the ith element of v2. 

7,intrinsic中的mnemonic释义
vrA.t : t表示所有的类型,vr表示向量寄存器v0−v39
vW.t : w表示destination ,v表示向量寄存器v0−v23
vlZ.t : vl表示v0−v23
arA.t : a表示general register file
?prX : 表示这条命令是否执行
?vprX : 向量运算中每一位的开关
srX : General notation for all SRF registers.
moduN : Modulo registers : modu0 through modu3
sX, sZ :Step registers: s0 through s7
sp: Stack Pointer
vacchZ.t : 中的acch为accumulator累加,acc表示v24−v39,acch表示v32−v39 
vaccZp.t : 中的p表示向量或累加器的高位或低位,用h (high) or l (low)表示 
vrZ0p.dc32 : 中的d表示unsigned 或singed don't care 
#[u]immXx  : 立即数,X表示标识符,x表示多少bit长
          prZ,vprZ :这是一个操作占位符,表示这里进行许多操作如:cmp, ffs, flcopy, fpcmp, max, min, prm,shiftl, shiftr, tst,vacccmp, vcmp, vcmpacc, vcmpmov,
                            vfpcmp, vld.h, vmax, vmin, vmov, vpop等
8,寻址模式
(#imm32).t: 直接寻址
(rN.ui).t [+pm]: 间接寻址
(rN.ui).t + #imm32: 间接寻址
(#uimmN32).t:长直接寻址
(rM.ui + rN.i).t[+pm]:索引寻址
(rM.ui +
其中:pm表示Post-modification相当于定语后置,进行地址的偏移修饰

9,数字的表示

10,符号的意义

 11,用ld或pop给寄存器赋值

Sign-/zero-extended表示 没有u的话,用0填充,有u用1填充
When storing or pushing a register, the high part is the first part written to memory.
When loading or popping a register, the low part is the first part read from memory.
 
12,vec-c 直接优化的数学运算:
1,vector inversion (向量倒置)  inv
2,vector (inverse) square root (向量平方根,或平方根的倒置)  sqrt / sqrti
原创粉丝点击