blob: 02ab8df3a6b76b0572c1ac8fcebc039f6e9c0589 [file] [log] [blame]
Tom Stellardca166212017-01-30 21:56:46 +00001//===- AMDGPULegalizerInfo.cpp -----------------------------------*- 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/// \file
10/// This file implements the targeting of the Machinelegalizer class for
11/// AMDGPU.
12/// \todo This should be generated by TableGen.
13//===----------------------------------------------------------------------===//
14
15#include "AMDGPULegalizerInfo.h"
16#include "llvm/CodeGen/ValueTypes.h"
Tom Stellardca166212017-01-30 21:56:46 +000017#include "llvm/IR/DerivedTypes.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000018#include "llvm/IR/Type.h"
Tom Stellardca166212017-01-30 21:56:46 +000019#include "llvm/Support/Debug.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000020#include "llvm/Target/TargetOpcodes.h"
Tom Stellardca166212017-01-30 21:56:46 +000021
22using namespace llvm;
23
Tom Stellardca166212017-01-30 21:56:46 +000024AMDGPULegalizerInfo::AMDGPULegalizerInfo() {
25 using namespace TargetOpcode;
26
Tom Stellarde0424122017-06-03 01:13:33 +000027 const LLT S1= LLT::scalar(1);
Tom Stellardff63ee02017-06-19 13:15:45 +000028 const LLT V2S16 = LLT::vector(2, 16);
Tom Stellardca166212017-01-30 21:56:46 +000029 const LLT S32 = LLT::scalar(32);
30 const LLT S64 = LLT::scalar(64);
31 const LLT P1 = LLT::pointer(1, 64);
32 const LLT P2 = LLT::pointer(2, 64);
33
Tom Stellardee6e6452017-06-12 20:54:56 +000034 setAction({G_ADD, S32}, Legal);
Tom Stellardaf552dc2017-06-23 15:17:17 +000035 setAction({G_AND, S32}, Legal);
Tom Stellardee6e6452017-06-12 20:54:56 +000036
Tom Stellardff63ee02017-06-19 13:15:45 +000037 setAction({G_BITCAST, V2S16}, Legal);
38 setAction({G_BITCAST, 1, S32}, Legal);
39
40 setAction({G_BITCAST, S32}, Legal);
41 setAction({G_BITCAST, 1, V2S16}, Legal);
42
Tom Stellarde0424122017-06-03 01:13:33 +000043 // FIXME: i1 operands to intrinsics should always be legal, but other i1
44 // values may not be legal. We need to figure out how to distinguish
45 // between these two scenarios.
46 setAction({G_CONSTANT, S1}, Legal);
Tom Stellarda0d67c72017-05-12 16:46:46 +000047 setAction({G_CONSTANT, S32}, Legal);
Tom Stellardca166212017-01-30 21:56:46 +000048 setAction({G_CONSTANT, S64}, Legal);
49
Tom Stellarddde28a82017-05-26 16:40:03 +000050 setAction({G_FCONSTANT, S32}, Legal);
51
Tom Stellardd0c6cf22017-10-27 23:57:41 +000052 setAction({G_FADD, S32}, Legal);
53
Tom Stellard3337d742017-08-02 22:56:30 +000054 setAction({G_FMUL, S32}, Legal);
55
Tom Stellardca166212017-01-30 21:56:46 +000056 setAction({G_GEP, P1}, Legal);
57 setAction({G_GEP, P2}, Legal);
58 setAction({G_GEP, 1, S64}, Legal);
59
Tom Stellard8cd60a52017-06-06 14:16:50 +000060 setAction({G_ICMP, S1}, Legal);
61 setAction({G_ICMP, 1, S32}, Legal);
62
Tom Stellardca166212017-01-30 21:56:46 +000063 setAction({G_LOAD, P1}, Legal);
64 setAction({G_LOAD, P2}, Legal);
65 setAction({G_LOAD, S32}, Legal);
66 setAction({G_LOAD, 1, P1}, Legal);
67 setAction({G_LOAD, 1, P2}, Legal);
68
Tom Stellard55038cd2017-07-26 20:00:53 +000069 setAction({G_OR, S32}, Legal);
70
Tom Stellard2860a422017-06-07 13:54:51 +000071 setAction({G_SELECT, S32}, Legal);
72 setAction({G_SELECT, 1, S1}, Legal);
73
Tom Stellardeb8f1e22017-06-26 15:56:52 +000074 setAction({G_SHL, S32}, Legal);
75
Tom Stellardca166212017-01-30 21:56:46 +000076 setAction({G_STORE, S32}, Legal);
77 setAction({G_STORE, 1, P1}, Legal);
78
79 // FIXME: When RegBankSelect inserts copies, it will only create new
80 // registers with scalar types. This means we can end up with
81 // G_LOAD/G_STORE/G_GEP instruction with scalar types for their pointer
82 // operands. In assert builds, the instruction selector will assert
83 // if it sees a generic instruction which isn't legal, so we need to
84 // tell it that scalar types are legal for pointer operands
85 setAction({G_GEP, S64}, Legal);
86 setAction({G_LOAD, 1, S64}, Legal);
87 setAction({G_STORE, 1, S64}, Legal);
88
89 computeTables();
90}