6fb01b687f3c16873d2e0873420e4f6fbc9d753c
1 //===-- AMDGPUUtil.cpp - TODO: Add brief description -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // TODO: Add full description
12 //===----------------------------------------------------------------------===//
14 #include "AMDGPUUtil.h"
15 #include "AMDGPURegisterInfo.h"
17 #include "llvm/CodeGen/MachineInstrBuilder.h"
18 #include "llvm/CodeGen/MachineRegisterInfo.h"
19 #include "llvm/Support/ErrorHandling.h"
20 #include "llvm/Target/TargetInstrInfo.h"
21 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/Target/TargetRegisterInfo.h"
26 /* Some instructions act as place holders to emulate operations that the GPU
27 * hardware does automatically. This function can be used to check if
28 * an opcode falls into this category. */
29 bool llvm::isPlaceHolderOpcode(unsigned opcode
)
32 default: return false;
33 case AMDIL::EXPORT_REG
:
35 case AMDIL::LOAD_INPUT
:
37 case AMDIL::MASK_WRITE
:
38 case AMDIL::RESERVE_REG
:
43 bool llvm::isTransOp(unsigned opcode
)
46 default: return false;
55 case AMDIL::MUL_LIT_r600
:
56 case AMDIL::MUL_LIT_eg
:
60 case AMDIL::EXP_IEEE_r600
:
61 case AMDIL::EXP_IEEE_eg
:
62 case AMDIL::LOG_CLAMPED_r600
:
63 case AMDIL::LOG_IEEE_r600
:
64 case AMDIL::LOG_CLAMPED_eg
:
65 case AMDIL::LOG_IEEE_eg
:
71 bool llvm::isTexOp(unsigned opcode
)
74 default: return false;
75 case AMDIL::TEX_SAMPLE
:
76 case AMDIL::TEX_SAMPLE_C
:
77 case AMDIL::TEX_SAMPLE_L
:
78 case AMDIL::TEX_SAMPLE_C_L
:
79 case AMDIL::TEX_SAMPLE_LB
:
80 case AMDIL::TEX_SAMPLE_C_LB
:
81 case AMDIL::TEX_SAMPLE_G
:
82 case AMDIL::TEX_SAMPLE_C_G
:
87 bool llvm::isReductionOp(unsigned opcode
)
90 default: return false;
91 case AMDIL::DOT4_r600
:
97 bool llvm::isFCOp(unsigned opcode
)
100 default: return false;
101 case AMDIL::BREAK_LOGICALZ_f32
:
102 case AMDIL::BREAK_LOGICALNZ_i32
:
103 case AMDIL::BREAK_LOGICALZ_i32
:
104 case AMDIL::CONTINUE_LOGICALNZ_f32
:
105 case AMDIL::IF_LOGICALNZ_i32
:
106 case AMDIL::IF_LOGICALZ_f32
:
110 case AMDIL::IF_LOGICALNZ_f32
:
111 case AMDIL::WHILELOOP
:
116 void AMDGPU::utilAddLiveIn(MachineFunction
* MF
, MachineRegisterInfo
& MRI
,
117 const struct TargetInstrInfo
* TII
, unsigned physReg
, unsigned virtReg
)
119 if (!MRI
.isLiveIn(physReg
)) {
120 MRI
.addLiveIn(physReg
, virtReg
);
121 BuildMI(MF
->front(), MF
->front().begin(), DebugLoc(),
122 TII
->get(TargetOpcode::COPY
), virtReg
)
125 MRI
.replaceRegWith(virtReg
, MRI
.getLiveInVirtReg(physReg
));