Skip to content

Instantly share code, notes, and snippets.

@FernandoS27
Created August 30, 2018 17:58
Show Gist options
  • Save FernandoS27/3ab6e3c24cedf7f0b33f7f8a1b0693d4 to your computer and use it in GitHub Desktop.
Save FernandoS27/3ab6e3c24cedf7f0b33f7f8a1b0693d4 to your computer and use it in GitHub Desktop.
CSETP stands for Constrol Code Set Predicate. It's a predicate set instruction that works on an special register called cc (Control Code)
it takes 2 input predicates to modify and one extra that's logicaly compared to flag in cc being tested.
Control Code is only updated when the instruction that generates it has bit 47 on. cc apears to be 32 bits wide and the values of cc are:
{ 0x0000000000000000ull, 0x0000000000001f00ull, N("f") },
{ 0x0000000000000100ull, 0x0000000000001f00ull, N("lt") },
{ 0x0000000000000200ull, 0x0000000000001f00ull, N("eq") },
{ 0x0000000000000300ull, 0x0000000000001f00ull, N("le") },
{ 0x0000000000000400ull, 0x0000000000001f00ull, N("gt") },
{ 0x0000000000000500ull, 0x0000000000001f00ull, N("ne") },
{ 0x0000000000000600ull, 0x0000000000001f00ull, N("ge") },
{ 0x0000000000000700ull, 0x0000000000001f00ull, N("num") },
{ 0x0000000000000800ull, 0x0000000000001f00ull, N("nan") },
{ 0x0000000000000900ull, 0x0000000000001f00ull, N("ltu") },
{ 0x0000000000000a00ull, 0x0000000000001f00ull, N("equ") },
{ 0x0000000000000b00ull, 0x0000000000001f00ull, N("leu") },
{ 0x0000000000000c00ull, 0x0000000000001f00ull, N("gtu") },
{ 0x0000000000000d00ull, 0x0000000000001f00ull, N("neu") },
{ 0x0000000000000e00ull, 0x0000000000001f00ull, N("geu") },
{ 0x0000000000000f00ull, 0x0000000000001f00ull },
{ 0x0000000000001000ull, 0x0000000000001f00ull, N("off") },
{ 0x0000000000001100ull, 0x0000000000001f00ull, N("lo") },
{ 0x0000000000001200ull, 0x0000000000001f00ull, N("sff") },
{ 0x0000000000001300ull, 0x0000000000001f00ull, N("ls") },
{ 0x0000000000001400ull, 0x0000000000001f00ull, N("hi") },
{ 0x0000000000001500ull, 0x0000000000001f00ull, N("sft") },
{ 0x0000000000001600ull, 0x0000000000001f00ull, N("hs") },
{ 0x0000000000001700ull, 0x0000000000001f00ull, N("oft") },
{ 0x0000000000001800ull, 0x0000000000001f00ull, N("csm_ta") },
{ 0x0000000000001900ull, 0x0000000000001f00ull, N("csm_tr") },
{ 0x0000000000001a00ull, 0x0000000000001f00ull, N("csm_mx") },
{ 0x0000000000001b00ull, 0x0000000000001f00ull, N("fcsm_ta") },
{ 0x0000000000001c00ull, 0x0000000000001f00ull, N("fcsm_tr") },
{ 0x0000000000001d00ull, 0x0000000000001f00ull, N("fcsm_mx") },
{ 0x0000000000001e00ull, 0x0000000000001f00ull, N("rle") },
{ 0x0000000000001f00ull, 0x0000000000001f00ull, N("rgt") },
n/a
n/a
"csetp.lt.and P0 PT PT" gets the flag lt in cc and does an 'and' with PT, saves the value only P0 (PT is constant)
FORMAT:
union {
BitField<0, 3, u64> pred0;
BitField<3, 3, u64> pred3;
BitField<13, 5, PredOperation> flag; // flag in cc
BitField<39, 3, u64> pred39;
BitField<42, 1, u64> neg_pred39;
BitField<45, 4, PredOperation> op; // op with pred39
} csetp;
SMO output:
CSETP.24.0 P7, P0, P7 // P7 = PT, always true predicate:
which is:
CSETP.oft.and PT, P0, PT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment