cr88192

Very preliminary FR2E spec.

Apr 29th, 2020
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.61 KB | None | 0 0
  1. Simplified FRBC intended mostly as a 3AC IR for object files.
  2. * This may be intended as a possible alternative to RIL3.
  3. * May incorporate parts of RIL3.
  4.  
  5.  
  6. Will differ from RIL3 in that it will not represent a serialization of the conversion process from ASTs, but will instead be a dump of the compiler state following the conversion process.
  7.  
  8.  
  9.  
  10. == Packaging ==
  11.  
  12. Will use a TLV package.
  13. Words will be encoded in little-endian order, with structures being byte-aligned.
  14.  
  15. TLV Chunks will begin with a 16-bit WORD, with LSB bits identifying the type:
  16. * zz00: WORD,TWOCC (16K)
  17. * zz01: DWORD,TWOCC (1GB)
  18. * zz10: DWORD,FOURCC (1GB)
  19. * z011: Small Tag (32B with a BYTE tag)
  20. ** Tag is in bits (15:8)
  21. ** Length is in bits (7:3)
  22.  
  23. TWOCC tags will use case to identify Tag Type:
  24. * 'aa': Structure or Data
  25. ** Contains a raw structure or other Non-TLV data.
  26. * 'AA': Compound Tag
  27. ** Contains TLV tags.
  28. * A letter followed by a non-leter will behave as one of the above.
  29.  
  30. Non-ASCII characters are not allowed in a TWOCC or FOURCC. A valid TWOCC or FOURCC will be padded as needed with spaces.
  31.  
  32. A narrower tag may be promoted to a wider one by padding with zeroes.
  33. As such, the value range of the tag will be able to identify the type of the tag if it had been promoted from a narrower type.
  34.  
  35. Tags will include the tag header in their length, thus the small BYTE tag is limited to 30 bytes of data. If this limit is exceeded, it will be promoted to a TWOCC.
  36.  
  37. BYTE tags:
  38. * 00: Reserved
  39. * 01..7F: Context Dependent
  40. * 80: Long String Attribute
  41. * 81: Short String Attribute
  42. * 82: Integer Attribute
  43.  
  44.  
  45. === Top-Level ===
  46.  
  47. FOURCC: 'FR2E'
  48. * Represents a FRBC2E image.
  49. * Size will cover the entire image.
  50. * This will contain most of the other top-level tags.
  51.  
  52. FOURCC: 'LITD'
  53. * Literal Table Data
  54. * Consists of Literal Table entries packed end to end.
  55.  
  56. FOURCC: 'GBLD'
  57. * Global Table Data
  58. * Consists of Global Table entries packed end to end.
  59.  
  60. FOURCC: 'strs'
  61. * Image Strings Table
  62. * Consists of String Data.
  63. * Strings will be nominally encoded using NUL-terminated M-UTF-8.
  64.  
  65. FOURCC: 'strz'
  66. * Image Strings Table (LZ4)
  67. * Same as 'strs', just stored in a compressed form.
  68.  
  69. FOURCC: 'stri'
  70. * Image Strings Table Index
  71. * Stores a delta-encoded array of string offsets.
  72. * Each will be stored as the difference from the prior offset, using a UVLI.
  73. * String Indices 0 and 1 will be special.
  74. ** 0 will encode NULL.
  75. ** 1 will encode an empty string.
  76. ** As such, this table will begin with string index 2.
  77.  
  78. FOURCC: 'vops'
  79. * Virtual Opcodes
  80. * Will consist of an array of serialized opcodes.
  81.  
  82. FOURCC: 'vtrs'
  83. * Virtual Traces
  84. * Will consist of an array of serialized traces.
  85. * Each trace will exist as a span of opcodes.
  86.  
  87.  
  88. Within LITD:
  89. * TWOCC: 'LI' (Generic)
  90. ** Literal Info Entry
  91. ** Contains a literal-info object.
  92. * TWOCC: 'ST' (Structure)
  93. ** Defines a 'struct' type.
  94. * TWOCC: 'UN' (Union)
  95. ** Defines a 'union' type.
  96. * TWOCC: 'CL' (Class)
  97. ** Defines a reference class or interface type.
  98. * TWOCC: 'FN' (Function)
  99. ** Defines a function signature (function pointers).
  100. * TWOCC: 'TY' (Typedef)
  101. ** Allows defining one type in terms of another.
  102.  
  103. Within 'GBLD':
  104. * TWOCC: 'RI' (Generic)
  105. ** Contains a global-info object.
  106. * TWOCC: 'FN' (Function)
  107. ** Defines the contents of a function or a function prototype.
  108. * TWOCC: 'GV' (Global Variable)
  109. ** Defines the contents of a global or static variable.
  110.  
  111. Within Literal and Global Entries
  112. * BYTE: 's' (Signature String)
  113. * BYTE: 'f' (Flags String)
  114. * BYTE: 'n' (Name String)
  115. * BYTE: 'q' (QName String)
  116. * BYTE: 'v' (GV: Value, Register ID)
  117. * BYTE: 't' (FN: Text / Code Traces, Trace-Table Index)
  118.  
  119. Variable List Tags
  120. * BYTE: 'F' (Fields)
  121. * BYTE: 'A' (Args)
  122. * BYTE: 'L' (Locals)
  123. * BYTE: 'R' (Temporaries)
  124. * BYTE: 'S' (Static Vars)
  125.  
  126. Within Variable-Lists:
  127. * BYTE: 'V' (Variable)
  128. ** Typically contain 's', 'f', and 'n' fields.
  129. ** Static variables may also have a QName.
  130. *** They will alias with a corresponding global with a matching QName.
  131.  
  132.  
  133. String tags will be encoded as an SVLI possibly followed by character data.
  134. If the VLI is positive, it represents an index into the string table.
  135. If the VLI is negative, it encodes the string inline.
  136.  
  137. A value of -1 will indicate a simple NUL-terminated string.
  138.  
  139.  
  140. Variable Lists will depend on what they are contained with, and some lists may be reused for other purposes in other entry types.
  141.  
  142.  
  143. === VLI ===
  144.  
  145. UVLI:
  146. * 0.. 127 0xxx-xxxx
  147. * 128..16383 10xx-xxxx xxxx-xxxx
  148. * 16384.. 2M 110x-xxxx xxxx-xxxx xxxx-xxxx
  149. * 2M.. 256M 1110-xxxx xxxx-xxxx xxxx-xxxx xxxx-xxxx
  150. * ...
  151.  
  152. OpVLI:
  153. * 0x00000000..0x000000DF xxxx-xxxx
  154. * 0x000000E0..0x00000FFF 1110-xxxx xxxx-xxxx
  155. * 0x00001000..0x0007FFFF 1111-0xxx xxxx-xxxx(x2)
  156. * 0x00080000..0x03FFFFFF 1111-10xx xxxx-xxxx(x3)
  157. * 0x04000000..0xFFFFFFFF 1111-1100 xxxx-xxxx(x4)
  158.  
  159. UVLI (32-bit):
  160. * 0x00000000..0x0000007F 0xxx-xxxx
  161. * 0x00000080..0x00003FFF 10xx-xxxx xxxx-xxxx
  162. * 0x00004000..0x001FFFFF 110x-xxxx xxxx-xxxx xxxx-xxxx
  163. * 0x00200000..0x0FFFFFFF 1110-xxxx xxxx-xxxx xxxx-xxxx xxxx-xxxx
  164. * 0x10000000..0xFFFFFFFF 1111-0zzz xxxx-xxxx xxxx-xxxx xxxx-xxxx xxxx-xxxx
  165.  
  166. UVLI (64-bit):
  167. * 0x0000000000000000..0x000000000000007F 0xxx-xxxx
  168. * 0x0000000000000080..0x0000000000003FFF 10xx-xxxx xxxx-xxxx
  169. * 0x0000000000004000..0x00000000001FFFFF 110x-xxxx xxxx-xxxx(x2)
  170. * 0x0000000000200000..0x000000000FFFFFFF 1110-xxxx xxxx-xxxx(x3)
  171. * 0x0000000010000000..0x00000007FFFFFFFF 1111-0xxx xxxx-xxxx(x4)
  172. * 0x0000008000000000..0x000003FFFFFFFFFF 1111-10xx xxxx-xxxx(x5)
  173. * 0x0000400000000000..0x0001FFFFFFFFFFFF 1111-110x xxxx-xxxx(x6)
  174. * 0x0020000000000000..0x00FFFFFFFFFFFFFF 1111-1110 xxxx-xxxx(x7)
  175. * 0x1000000000000000..0xFFFFFFFFFFFFFFFF 1111-1111 xxxx-xxxx(x8)
  176.  
  177. UVLI (128-bit):
  178. * 0x0000000000000000..0x000000000000007F 0xxx-xxxx
  179. * 0x0000000000000080..0x0000000000003FFF 10xx-xxxx xxxx-xxxx
  180. * ...
  181. * 0x0020000000000000..0x00FFFFFFFFFFFFFF 1111-1110 xxxx-xxxx(x7)
  182. * 0x1000000000000000..0x7FFFFFFFFFFFFFFF 1111-1111 0xxx-xxxx xxxx-xxxx(x7)
  183. * 0x8000000000000000..0x3FFFFFFFFFFFFFFFFF 1111-1111 10xx-xxxx xxxx-xxxx(x8)
  184. * ...
  185.  
  186. Normal UVLI and SVLI values will use the 64-bit variety.
  187. * The 32-bit case is a subset, and will be used for Tags and IDs.
  188. * Most 128-bit values will also use the 64-bit variety.
  189. ** However, they will encode the value as a pair.
  190.  
  191. SVLI:
  192. * Folds sign into LSB
  193. * 0, -1, 1, -2, 2, ...
  194.  
  195.  
  196. === Type Signatures ===
  197.  
  198. Typed signatures are encoded as strings, with characters indicating value types.
  199.  
  200. * 'a': signed char
  201. * 'b': bool
  202. * 'c': char
  203. * 'd': double
  204. * 'e': long double
  205. * 'f': float
  206. * 'g': float128
  207. * 'h': unsigned char
  208. * 'i': int
  209. * 'j': unsigned int
  210. * 'k': float16/half
  211. * 'l': long
  212. * 'm': unsigned long
  213. * 'n': int128
  214. * 'o': unsigned int128
  215. * 'p': intptr
  216. * 'q': reserved
  217. * 'r': variant (64-bit tagged value)
  218. * 's': short
  219. * 't': unsigned short
  220. * 'u': bfloat16
  221. * 'v': void
  222. * 'w': wchar
  223. * 'x': long long
  224. * 'y': unsigned long long
  225. * 'z': vararg
  226. * 'Ca': __vec2f
  227. * 'Cb': __vec3f
  228. * 'Cc': __vec4f
  229. * 'Cd': _Complex double / __dcomplex
  230. * 'Ce': _Complex long double
  231. * 'Cf': _Complex float / __fcomplex
  232. * 'Cg': _Complex float128
  233. * 'Ch': __vec2d
  234. * 'Ci': __vec4si
  235. * 'Cj': __vec4ui
  236. * 'Ck': _Complex float16
  237. * 'Cl':
  238. * 'Cm': __m64
  239. * 'Cn': __m128
  240. * 'Co': object
  241. * 'Cp': __m128p / __packed __m128
  242. * 'Cq': __quatf
  243. * 'Cr': short variant
  244. * 'Cs': string
  245. * 'Ct':
  246. * 'Cu': _Complex bfloat16
  247. * 'Cv': __vec4sw
  248. * 'Cw': __vec4uw
  249. * 'Cx': variant this
  250. * 'Cy': variant class
  251. * 'Cz': variant vararg
  252. * 'Da': auto
  253. * 'Di': __vec2si
  254. * 'Dj': __vec2ui
  255. * 'Dn': nullptr
  256. * 'Dz': va_list
  257. * 'A{sz};{sig}: Array
  258. * 'A{a..z}{sig}': Pointer/Array Class Modifier
  259. * 'L{qname};': Tag Class
  260. * 'P{sig}': Pointer
  261. * 'Q{sig}': Tag Array
  262. * 'R{sig}': Reference to Type.
  263. * 'U{name};': Extended Type
  264. * 'W{sig}': Wide Pointer
  265. * 'X{name};': Struct/Union
  266. * '({args}){ret}': Function Signature
  267.  
  268. Pointer/Array Class Modifer:
  269. * 'Ab': Packed / Big Endian
  270. * 'Af': Far
  271. * 'Al': Packed / Little Endian
  272.  
  273. * 'An': Near
  274. * 'Ap': Packed
  275. * 'Aw': ? Wide
  276.  
  277.  
  278. === Flag String ===
  279.  
  280. * a: abstract ("__abstract")
  281. * b: bigendian ("__bigendian")
  282. * c: cdecl ("__cdecl")
  283. * d: delegate ("__delegate")
  284. * e: extern ("extern")
  285. * f: fastcall ("__fastcall")
  286. * g: getter ("__get")
  287. * h: setter ("__set")
  288. * i: inline ("inline" / "__inline")
  289. * j: final/const2 ("type * const")
  290. * k: const ("const type")
  291. * l: ltlendian ("__ltlendian")
  292. * m: packed ("__packed" / "__unaligned", struct=packed, pointer=unaligned)
  293. * n: native ("__native")
  294. * o: override|restrict ("__override", "__restrict", "restrict")
  295. * p: public ("public")
  296. * q: private ("private")
  297. * r: protected ("protected")
  298. * s: static ("static")
  299. * t: thiscall (virtual method function)
  300. * u: (special case)
  301. * v: virtual|volatile ("virtual"/"volatile")
  302. * w: stdcall ("__stdcall")
  303. * x: xcall ("__xcall")
  304. * y: transient ("__transient")
  305. * z: reserved
  306.  
  307. * Cb: reference ("&type")
  308. * Ce: event ("__event")
  309. * Cf: interrupt ("__interrupt")
  310. * Ci: interface ("__interface")
  311. * Cs: synchronized ("__synchronized")
  312. * Ct: thread ("__thread")
  313.  
  314. * Cw: wide ("__wide")
  315. * Cx: near pointer ("__near")
  316. * Cy: far pointer ("__far")
  317.  
  318. * De: dllexport
  319. * Di: dllimport
  320.  
  321. * U{name}; //named flag
  322.  
  323.  
  324. == Virtual Opcodes ==
  325.  
  326. Virtual Opcodes (or VOPs) will be encoded via a bitmask followed by various parameters.
  327. The bitmask will encode which parameters are present.
  328. Unused parameters will generally either set to zero or some other unused-value state.
  329.  
  330. Typical Layout:
  331. * UVLI mask;
  332. * (mask& 1) ? UVLI opn; //Opcode Number
  333. * (mask& 2) ? UVLI opr; //Operator Number
  334. * (mask& 128) ? UVLI prd; //Predication Mode
  335. * (mask& 4) ? TYPE type; //Base/Destination Type
  336. * (mask& 256) ? TYPE stype; //Source Type
  337. * (mask& 8) ? REG dst; //Destination Register
  338. * (mask& 16) ? REG srca; //Source Register A
  339. * (mask& 32) ? REG srcb; //Source Register B
  340. * (mask& 512) ? REG srcc; //Source Register C
  341. * (mask&1024) ? REG srcd; //Source Register D
  342. * (mask& 64) ? IMMED imm; //Operation Immediate
  343.  
  344.  
  345. Typically, 'opn' will always be present, so the interpretation of the low two mask bits will be special:
  346. * 00: Repeat Previous Mask
  347. * 01: Encodes opn by itself.
  348. * 10: The opn and opr fields will be merged into a bit-interleved value.
  349. * 11: Both opn and opr will be encoded separately.
  350.  
  351. In the Repeat-Mask case, recent opcode masks may be reused.
  352. This will implement a Move-To-Front scheme with the most recent 32 masks.
  353.  
  354. In the bit-interleved opn+opr case:
  355. * yxyxyxyx, where yyy is the opcode number, and xxx the operator.
  356.  
  357.  
  358. Opcode Numbers:
  359. * VOP_UNARY 0x01
  360. * VOP_BINARY 0x02
  361. * VOP_LABEL 0x03
  362. * VOP_JMP 0x04
  363. * VOP_MOV 0x05
  364. * VOP_JCMP_ZERO 0x06
  365. * VOP_JCMP 0x07
  366. * VOP_CALL 0x08
  367. * VOP_CSRV 0x09
  368. * VOP_RETDFL 0x0A
  369. * VOP_RETV 0x0B
  370. * VOP_RET 0x0C
  371. * VOP_CONV 0x0D
  372. * VOP_DBGFN 0x0E
  373. * VOP_DBGLN 0x0F
  374. * VOP_COMPARE 0x10
  375. * VOP_LDIXIMM 0x11
  376. * VOP_STIXIMM 0x12
  377. * VOP_LDIX 0x13
  378. * VOP_STIX 0x14
  379. * VOP_LEAIMM 0x15
  380. * VOP_LEA 0x16
  381. * VOP_LDAVAR 0x17
  382. * VOP_SIZEOFVAR 0x18
  383. * VOP_DIFFPTR 0x19
  384. * VOP_OFFSETOF 0x1A
  385. * VOP_LOADSLOT 0x1B
  386. * VOP_STORESLOT 0x1C
  387. * VOP_LOADSLOTADDR 0x1D
  388. * VOP_LOADSLOTADDRID 0x1E
  389. * VOP_INITOBJ 0x1F
  390. * VOP_DROPOBJ 0x20
  391. * VOP_INITARR 0x21
  392. * VOP_INITOBJARR 0x22
  393. * VOP_LOADINITARR 0x23
  394. * VOP_LOADINITOBJARR 0x24
  395. * VOP_VA_START 0x25
  396. * VOP_VA_END 0x26
  397. * VOP_VA_ARG 0x27
  398. * VOP_CSELCMP 0x28
  399. * VOP_CSELCMP_Z 0x29
  400. * VOP_JMPTAB 0x2A
  401. * VOP_OBJCALL 0x2B
  402. * VOP_PREDCMP 0x2C
  403. * VOP_PREDCMP_Z 0x2D
  404. * VOP_PREDSYNC 0x2E //sync registers
  405. * VOP_CALL_INTRIN 0x2F
  406.  
  407. Operator Numbers:
  408. * BINOP_ADD 0x00
  409. * BINOP_SUB 0x01
  410. * BINOP_MUL 0x02
  411. * BINOP_DIV 0x03
  412. * BINOP_MOD 0x04
  413. * BINOP_AND 0x05
  414. * BINOP_OR 0x06
  415. * BINOP_XOR 0x07
  416. * BINOP_SHL 0x08
  417. * BINOP_SHR 0x09
  418. * BINOP_SHRR 0x0A
  419. * BINOP_MULH 0x0B
  420. * BINOP_UMULH 0x0C
  421. * BINOP_UDIV 0x0D
  422.  
  423. * UNOP_MOV 0x00
  424. * UNOP_NEG 0x01
  425. * UNOP_NOT 0x02
  426. * UNOP_LNOT 0x03
  427. * UNOP_INC 0x04
  428. * UNOP_DEC 0x05
  429.  
  430. * CMP_EQ 0x00
  431. * CMP_NE 0x01
  432. * CMP_LT 0x02
  433. * CMP_GT 0x03
  434. * CMP_LE 0x04
  435. * CMP_GE 0x05
  436. * CMP_AL 0x06
  437. * CMP_NV 0x07
  438. * CMP_TST 0x08 //if(x&y)
  439. * CMP_NTST 0x09 //if(!(x&y))
  440.  
  441.  
  442.  
  443. === Type IDs ===
  444.  
  445. Will be encoded as a VLI with low-bit tags.
  446. * zzzz0: String Index (Type Signature)
  447. * zzz01: Simple Type
  448. * zzz11: Repeat Type (Move to Front)
  449.  
  450. The most recently coded 32 types will retained.
  451. Whenever a new type is encoded, it is added to the front of the list.
  452. Repeating a prior type will move it to the front of the list.
  453.  
  454. The simple type will be laid out as:
  455. * (11:8): Indirection Level
  456. * ( 7:0): Base Type (primitive types only).
  457.  
  458.  
  459. === Register IDs ===
  460.  
  461. Registers will be encoded as a VLI with a tag in the low order bits.
  462.  
  463. Register:
  464. * zzzz000: Repeat
  465. * zzzz010: Temporary
  466. * zzzz100: Arg
  467. * zzzz110: Local
  468. * zzz0001: Global Index
  469. * zzz0101: Literal Table Index
  470. * zzz1001: Integer Constant
  471. * zzz1101: String Table Index
  472. * zz00011: Global Address
  473. * zz01011: Integer Constant with 4b subtype.
  474. * zz10011: Long Constant (Inline)
  475. * zz11011: Wide-String Table Index
  476. * z000111: 'this' Index
  477.  
  478. * 0001111: Raw Long Constant (SVLI follows)
  479. * 0101111: Raw Double Constant (SVLI follows)
  480. * 1001111: Raw Int128 Constant (SVLI pair follows)
  481. * 1101111: Raw Float128 Constant (SVLI pair follows)
  482.  
  483.  
  484. Repeat will repeat a recently seen Register ID.
  485. The most recently coded 32 Register IDs will retained.
  486. It will encode an index into a table of recently seen Register IDs.
  487. Repeating a value will cause it to be moved to the front of the list.
  488. If any other value is encoded, it will be added to the front of the list.
  489.  
  490. Temporary, Arg, and Local will use a bit-interleved index.
  491. * yxyxyxyx, where yyy is the sequence, and xxx the base index.
  492.  
  493. The sequence number will indicate which version of a given register is used.
  494. * Assigning to a register gives it a new sequence value.
  495. * A block where multiple paths converge may also increment a registers' sequence.
  496. ** This will be known as a 'phi' operation.
  497.  
  498. The 'this' Index will be encoded similarly to a Local, however it will encode a path within the 'this' object. The base index will encode the field ID, whereas the sequence will encode how many levels to go up from the current class.
  499.  
  500.  
  501. Global and Literal table indices will be an index number into the global or literal table.
  502.  
  503. String Table Index will be an index into the string table.
  504.  
  505.  
  506. Integer Constant with 4b Subtype:
  507. * 0..7: Will encode various integer types.
  508. ** 0: int32_t / 'int'
  509. ** 1: uint32_t / 'unsigned int'
  510. ** 2: int64_t / 'long long'
  511. ** 3: uint64_t / 'unsigned long long'
  512. ** 4: int8_t / 'char'
  513. ** 5: uint8_t / 'unsigned char'
  514. ** 6: int16_t / 'short'
  515. ** 7: uint16_t / 'unsigned short'
  516. * 8: Escape Case, Reserved
  517. * 9..11: Reserved
  518. * 12 Will encode a 32-bit float of type 'float'.
  519. * 13 Will encode a 32-bit float of type 'double'.
  520. * 14 Will encode a 16-bit half-float of type 'float'.
  521. * 15 Will encode a 16-bit half-float of type 'double'.
  522.  
  523. Values for these subtypes, including for floating-point values, will be stored in a sign-folded format.
  524.  
  525.  
  526. === Immed ===
  527.  
  528. This will be a fixed immediate field used by certain operations.
  529.  
  530. Will be encoded as a UVLI followed by other data.
  531. The low 4 bits of this UVLI will serve as a tag.
  532. The remaining high bits may be used as a value.
  533.  
  534. Tag (High-bit Value):
  535. * 0: Repeat (Index; Certain Types)
  536. * 1: Negative Int (Negative Value)
  537. * 2: Positive Int (Positive Value)
  538. * 3: Label (Label ID)
  539. * 4: String (String Index)
  540. * 5: Call Argument List (Argument Count)
  541. * 6: Jump Table (Label Count)
  542. * 7: Structure/Field ID (Interleved)
  543.  
  544.  
  545. Repeat will exclude 5 and 6 but may repeat other immediate types.
  546. As before, this will use a Move-To-Front scheme.
  547. Tags 5 and 6 will be entirely ignored by the MTF mechanism.
  548.  
  549.  
  550. The Structure/Field ID will consist of the literal-table index being bit-interleved with the field ID.
  551. * yxyxyxyx, where yyy is the Field ID, and xxx the Literal Index.
  552.  
  553. If high bits of Tag 7 hold 0, then the index will be encoded as a pair of numbers following the tag.
  554.  
  555.  
  556. The Label ID will essentially be a magic number which associates branches with code labels. Control flow is not allowed between functions, but the label numbers are required to be unique across all functions in the image. It is encoded as an unsigned value.
  557.  
  558. The String is an index into the string table.
  559.  
  560. The Call Argument List will encode the number of arguments in the high bits, followed by the same number of Register ID values.
  561.  
  562. The Jump Table will encode the number of jump labels in the high bits, followed by (n+1) Label IDs. The final LabelID will encode the 'default' label, which will be the target for values of the range covered by the table.
  563.  
  564.  
  565. == Virtual Traces ==
  566.  
  567. Virtual Traces will encode a span of Virtual Opcodes.
  568.  
  569. Layout:
  570. * SVLI b_ops; //base opcode
  571. * SVLI n_ops; //number of opcodes
  572. * SVLI tr_fl; //trace flags
  573.  
  574. The base for a trace will be relative to the start of the parent function.
  575. For normal traces, all three fields will be positive.
  576.  
  577. If b_ops is negative, it encodes an absolute opcode number.
  578. This number will be the relative zero-index for the following traces.
  579. This encoding will be used for the first trace in a function, with the other traces using a positive index.
  580.  
  581. The n_ops field will always be positive for a normal trace.
  582. If the n_ops field is negative, it will instead encode a function-body header.
  583.  
  584.  
  585. A function body header will be defined as:
  586. * SVLI b_vtr; //Base index of first Trace in 'vtrs' (neg abs index)
  587. * SVLI n_vtr; //Total number of traces in function (neg count)
  588. * SVLI gblid; //Global-Index for function (neg index)
  589.  
  590. The function header will use up 1 index in the trace table, and typically follow after the traces for the function.
Add Comment
Please, Sign In to add comment