@@ -33,6 +33,55 @@ The AMDGPU back-end uses the following address space mapping:
33
33
The terminology in the table, aside from the region memory space, is from the
34
34
OpenCL standard.
35
35
36
+ Trap Handler ABI
37
+ ----------------
38
+ The OS element of the target triple controls the trap handler behavior.
39
+
40
+ HSA OS
41
+ ^^^^^^
42
+ For code objects generated by AMDGPU back-end for the HSA OS, the runtime
43
+ installs a trap handler that supports the s_trap instruction with the following
44
+ usage:
45
+
46
+ +--------------+-------------+-------------------+----------------------------+
47
+ | Usage |Code Sequence|Trap Handler Inputs|Description |
48
+ +==============+=============+===================+============================+
49
+ | reserved |s_trap 0x00 | |Reserved by hardware. |
50
+ +--------------+-------------+-------------------+----------------------------+
51
+ | HSA debugtrap |s_trap 0x01 |SGPR0-1: queue_ptr |Reserved for HSA debugtrap |
52
+ | (arg) | |VGPR0: arg |intrinsic (not implemented).|
53
+ +--------------+-------------+-------------------+----------------------------+
54
+ | llvm.trap |s_trap 0x02 |SGPR0-1: queue_ptr |Causes dispatch to be |
55
+ | | | |terminated and its |
56
+ | | | |associated queue put into |
57
+ | | | |the error state. |
58
+ +--------------+-------------+-------------------+----------------------------+
59
+ | llvm.debugtrap| s_trap 0x03 |SGPR0-1: queue_ptr |If debugger not installed |
60
+ | | | |handled same as llvm.trap. |
61
+ +--------------+-------------+-------------------+----------------------------+
62
+ | debugger |s_trap 0x07 | |Reserved for debugger |
63
+ | breakpoint | | |breakpoints. |
64
+ +--------------+-------------+-------------------+----------------------------+
65
+ | debugger |s_trap 0x08 | |Reserved for debugger. |
66
+ +--------------+-------------+-------------------+----------------------------+
67
+ | debugger |s_trap 0xfe | |Reserved for debugger. |
68
+ +--------------+-------------+-------------------+----------------------------+
69
+ | debugger |s_trap 0xff | |Reserved for debugger. |
70
+ +--------------+-------------+-------------------+----------------------------+
71
+
72
+ Non-HSA OS
73
+ ^^^^^^^^^^
74
+ For code objects generated by AMDGPU back-end for non-HSA OS, the runtime does
75
+ not install a trap handler. The llvm.trap and llvm.debugtrap instructions are
76
+ handler as follows:
77
+
78
+ =============== ============= ===============================================
79
+ Usage Code Sequence Description
80
+ =============== ============= ===============================================
81
+ llvm.trap s_endpgm Causes wavefront to be terminated.
82
+ llvm.debugtrap s_nop No operation. Compiler warning generated that
83
+ there is no trap handler installed.
84
+ =============== ============= ===============================================
36
85
37
86
Assembler
38
87
=========
@@ -261,47 +310,6 @@ VOP_SDWA examples:
261
310
262
311
For full list of supported instructions, refer to "Vector ALU instructions".
263
312
264
- Trap Handler ABI
265
- ----------------
266
- The Trap Handler suppored is implemented differently based on the host OS. OS
267
- is obtained from the appropriate element of the target triple HSA OS:
268
-
269
- .. code-block :: c++
270
-
271
- enum TrapHandlerAbi {
272
- TrapHandlerAbiNone = 0,
273
- TrapHandlerAbiHsa = 1
274
- };
275
-
276
- TrapHandlerAbi getTrapHandlerAbi() const {
277
- return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone;
278
- }
279
-
280
- For HSA OS, a trap handler is always enabled and that the following S_TRAP immediate
281
- operand codes are supported:
282
-
283
- .. code-block :: c++
284
-
285
- enum TrapCode {
286
- TrapCodeBreakPoint = 0,
287
- TrapCodeLLVMTrap = 1,
288
- TrapCodeLLVMDebugTrap = 2,
289
- TrapCodeHSADebugTrap = 3
290
- };
291
-
292
- - 0: Used for debugger breakpoint. If debugger is not installed causes dispatch
293
- to be terminated and its associated queue put into the error state.
294
- - 1: Used for llvm.trap..queue_ptr is in SGPR0-1. Causes dispatch to be
295
- terminated and its associated queue put into the error state.
296
- - 2: Used for llvm.debugtrap. queue_ptr is in SGPR0-1. If debugger not installed
297
- handled same as llvm.trap.
298
- - 3: Used for HSA DEBUGTRAP. queue_ptr is in SGPR0-1, the user code is in VGPR0.
299
-
300
- Graphics
301
- ^^^^^^^^
302
- For Graphics, S_ENDPGM is generated for llvm.trap. S_NOP is generated for
303
- llvm.debugtrap together with a warning that there is no trap handler installed.
304
-
305
313
HSA Code Object Directives
306
314
--------------------------
307
315
0 commit comments