blob: 6d0d42d4ff392a995db96e04dc53af7ea23ff15a [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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000016#ifndef LLVM_LIB_TARGET_R600_AMDGPUINSTRINFO_H
17#define LLVM_LIB_TARGET_R600_AMDGPUINSTRINFO_H
Tom Stellard75aadc22012-12-11 21:25:42 +000018
Chandler Carruthbe810232013-01-02 10:22:59 +000019#include "AMDGPURegisterInfo.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000020#include "llvm/Target/TargetInstrInfo.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000021#include <map>
22
23#define GET_INSTRINFO_HEADER
24#define GET_INSTRINFO_ENUM
Tom Stellard02661d92013-06-25 21:22:18 +000025#define GET_INSTRINFO_OPERAND_ENUM
Tom Stellard75aadc22012-12-11 21:25:42 +000026#include "AMDGPUGenInstrInfo.inc"
27
28#define OPCODE_IS_ZERO_INT AMDGPU::PRED_SETE_INT
29#define OPCODE_IS_NOT_ZERO_INT AMDGPU::PRED_SETNE_INT
30#define OPCODE_IS_ZERO AMDGPU::PRED_SETE
31#define OPCODE_IS_NOT_ZERO AMDGPU::PRED_SETNE
32
33namespace llvm {
34
Tom Stellard2e59a452014-06-13 01:32:00 +000035class AMDGPUSubtarget;
Tom Stellard75aadc22012-12-11 21:25:42 +000036class MachineFunction;
37class MachineInstr;
38class MachineInstrBuilder;
39
40class AMDGPUInstrInfo : public AMDGPUGenInstrInfo {
41private:
42 const AMDGPURegisterInfo RI;
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000043 virtual void anchor();
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000044protected:
Tom Stellard2e59a452014-06-13 01:32:00 +000045 const AMDGPUSubtarget &ST;
Tom Stellard75aadc22012-12-11 21:25:42 +000046public:
Tom Stellard2e59a452014-06-13 01:32:00 +000047 explicit AMDGPUInstrInfo(const AMDGPUSubtarget &st);
Tom Stellard75aadc22012-12-11 21:25:42 +000048
49 virtual const AMDGPURegisterInfo &getRegisterInfo() const = 0;
50
Matt Arsenault3f981402014-09-15 15:41:53 +000051public:
Tom Stellard81d871d2013-11-13 23:36:50 +000052 /// \returns the smallest register index that will be accessed by an indirect
53 /// read or write or -1 if indirect addressing is not used by this program.
Craig Topperee7b0f32014-04-30 05:53:27 +000054 int getIndirectIndexBegin(const MachineFunction &MF) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000055
56 /// \returns the largest register index that will be accessed by an indirect
57 /// read or write or -1 if indirect addressing is not used by this program.
Craig Topperee7b0f32014-04-30 05:53:27 +000058 int getIndirectIndexEnd(const MachineFunction &MF) const;
Tom Stellard81d871d2013-11-13 23:36:50 +000059
Matt Arsenault034d6662014-07-24 02:10:17 +000060 bool enableClusterLoads() const override;
61
Tom Stellard75aadc22012-12-11 21:25:42 +000062 bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
63 int64_t Offset1, int64_t Offset2,
Craig Topper5656db42014-04-29 07:57:24 +000064 unsigned NumLoads) const override;
Tom Stellard75aadc22012-12-11 21:25:42 +000065
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000066
Marek Olsaka93603d2015-01-15 18:42:51 +000067 /// \brief Return a target-specific opcode if Opcode is a pseudo instruction.
68 /// Return -1 if the target-specific opcode for the pseudo instruction does
69 /// not exist. If Opcode is not a pseudo instruction, this is identity.
70 int pseudoToMCOpcode(int Opcode) const;
71
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000072//===---------------------------------------------------------------------===//
73// Pure virtual funtions to be implemented by sub-classes.
74//===---------------------------------------------------------------------===//
Tom Stellard75aadc22012-12-11 21:25:42 +000075
Tom Stellard26a3b672013-10-22 18:19:10 +000076 /// \returns The register class to be used for loading and storing values
77 /// from an "Indirect Address" .
Tom Stellard1242ce92016-02-05 18:44:57 +000078 virtual const TargetRegisterClass *getIndirectAddrRegClass() const {
79 llvm_unreachable("getIndirectAddrRegClass() not implemented");
80 }
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000081
Tom Stellard682bfbc2013-10-10 17:11:24 +000082 /// \brief Given a MIMG \p Opcode that writes all 4 channels, return the
83 /// equivalent opcode that writes \p Channels Channels.
84 int getMaskedMIMGOp(uint16_t Opcode, unsigned Channels) const;
Tom Stellard26a3b672013-10-22 18:19:10 +000085
Tom Stellard75aadc22012-12-11 21:25:42 +000086};
87
Tom Stellard02661d92013-06-25 21:22:18 +000088namespace AMDGPU {
Matt Arsenaultf743b832015-09-25 18:09:15 +000089 LLVM_READONLY
Tom Stellard02661d92013-06-25 21:22:18 +000090 int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIndex);
91} // End namespace AMDGPU
92
Alexander Kornienkof00654e2015-06-23 09:49:53 +000093} // End llvm namespace
Tom Stellard75aadc22012-12-11 21:25:42 +000094
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000095#define AMDGPU_FLAG_REGISTER_LOAD (UINT64_C(1) << 63)
96#define AMDGPU_FLAG_REGISTER_STORE (UINT64_C(1) << 62)
97
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000098#endif