Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 8d22e6f

Browse files
author
Wei Ding
committed
AMDGPU : AMDGPU : Update AMDGPU Trap Handler ABI.
Differential Revision: http://reviews.llvm.org/D29913 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295745 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b335225 commit 8d22e6f

File tree

1 file changed

+49
-41
lines changed

1 file changed

+49
-41
lines changed

docs/AMDGPUUsage.rst

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,55 @@ The AMDGPU back-end uses the following address space mapping:
3333
The terminology in the table, aside from the region memory space, is from the
3434
OpenCL standard.
3535

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+
=============== ============= ===============================================
3685

3786
Assembler
3887
=========
@@ -261,47 +310,6 @@ VOP_SDWA examples:
261310
262311
For full list of supported instructions, refer to "Vector ALU instructions".
263312

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-
305313
HSA Code Object Directives
306314
--------------------------
307315

0 commit comments

Comments
 (0)