blob: 6203e575bfa9c9eb78bd5e0c3358930219ae9ef1 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- AMDGPUInstrInfo.h - AMDGPU Instruction Information ------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10/// \file
11/// \brief Contains the definition of a TargetInstrInfo class that is common
12/// to all AMD GPUs.
13//
14//===----------------------------------------------------------------------===//
15
Matt Arsenault6b6a2c32016-03-11 08:00:27 +000016#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUINSTRINFO_H
17#define LLVM_LIB_TARGET_AMDGPU_AMDGPUINSTRINFO_H
Tom Stellard75aadc22012-12-11 21:25:42 +000018
Tom Stellard75aadc22012-12-11 21:25:42 +000019#include "llvm/Target/TargetInstrInfo.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000020
21#define GET_INSTRINFO_HEADER
22#define GET_INSTRINFO_ENUM
Tom Stellard02661d92013-06-25 21:22:18 +000023#define GET_INSTRINFO_OPERAND_ENUM
Tom Stellard75aadc22012-12-11 21:25:42 +000024#include "AMDGPUGenInstrInfo.inc"
25
26#define OPCODE_IS_ZERO_INT AMDGPU::PRED_SETE_INT
27#define OPCODE_IS_NOT_ZERO_INT AMDGPU::PRED_SETNE_INT
28#define OPCODE_IS_ZERO AMDGPU::PRED_SETE
29#define OPCODE_IS_NOT_ZERO AMDGPU::PRED_SETNE
30
31namespace llvm {
32
Tom Stellard2e59a452014-06-13 01:32:00 +000033class AMDGPUSubtarget;
Tom Stellard75aadc22012-12-11 21:25:42 +000034class MachineFunction;
35class MachineInstr;
36class MachineInstrBuilder;
37
38class AMDGPUInstrInfo : public AMDGPUGenInstrInfo {
39private:
Tom Stellard2e59a452014-06-13 01:32:00 +000040 const AMDGPUSubtarget &ST;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000041
42 virtual void anchor();
43
Tom Stellard75aadc22012-12-11 21:25:42 +000044public:
Tom Stellard2e59a452014-06-13 01:32:00 +000045 explicit AMDGPUInstrInfo(const AMDGPUSubtarget &st);
Tom Stellard75aadc22012-12-11 21:25:42 +000046
Tom Stellard81d871d2013-11-13 23:36:50 +000047 /// \returns the smallest register index that will be accessed by an indirect
48 /// read or write or -1 if indirect addressing is not used by this program.
Craig Topperee7b0f32014-04-30 05:53:27 +000049 int getIndirectIndexBegin(const MachineFunction &MF) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000050
51 /// \returns the largest register index that will be accessed by an indirect
52 /// read or write or -1 if indirect addressing is not used by this program.
Craig Topperee7b0f32014-04-30 05:53:27 +000053 int getIndirectIndexEnd(const MachineFunction &MF) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000054
Matt Arsenault034d6662014-07-24 02:10:17 +000055 bool enableClusterLoads() const override;
56
Tom Stellard75aadc22012-12-11 21:25:42 +000057 bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
58 int64_t Offset1, int64_t Offset2,
Craig Topper5656db42014-04-29 07:57:24 +000059 unsigned NumLoads) const override;
Tom Stellard75aadc22012-12-11 21:25:42 +000060
Marek Olsaka93603d2015-01-15 18:42:51 +000061 /// \brief Return a target-specific opcode if Opcode is a pseudo instruction.
62 /// Return -1 if the target-specific opcode for the pseudo instruction does
63 /// not exist. If Opcode is not a pseudo instruction, this is identity.
64 int pseudoToMCOpcode(int Opcode) const;
65
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000066//===---------------------------------------------------------------------===//
67// Pure virtual funtions to be implemented by sub-classes.
68//===---------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +000069
Tom Stellard26a3b672013-10-22 18:19:10 +000070 /// \returns The register class to be used for loading and storing values
71 /// from an "Indirect Address" .
Tom Stellard1242ce92016-02-05 18:44:57 +000072 virtual const TargetRegisterClass *getIndirectAddrRegClass() const {
73 llvm_unreachable("getIndirectAddrRegClass() not implemented");
74 }
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000075
Tom Stellard682bfbc2013-10-10 17:11:24 +000076 /// \brief Given a MIMG \p Opcode that writes all 4 channels, return the
77 /// equivalent opcode that writes \p Channels Channels.
78 int getMaskedMIMGOp(uint16_t Opcode, unsigned Channels) const;
Tom Stellard75aadc22012-12-11 21:25:42 +000079};
80
Tom Stellard02661d92013-06-25 21:22:18 +000081namespace AMDGPU {
Matt Arsenaultf743b832015-09-25 18:09:15 +000082 LLVM_READONLY
Tom Stellard02661d92013-06-25 21:22:18 +000083 int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIndex);
84} // End namespace AMDGPU
85
Alexander Kornienkof00654e2015-06-23 09:49:53 +000086} // End llvm namespace
Tom Stellard75aadc22012-12-11 21:25:42 +000087
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000088#define AMDGPU_FLAG_REGISTER_LOAD (UINT64_C(1) << 63)
89#define AMDGPU_FLAG_REGISTER_STORE (UINT64_C(1) << 62)
90
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000091#endif