blob: 267f4807a788fee2af7b37464eb9f40ec0d8e184 [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"
17#include "llvm/IR/Type.h"
18#include "llvm/IR/DerivedTypes.h"
19#include "llvm/Target/TargetOpcodes.h"
20#include "llvm/Support/Debug.h"
21
22using namespace llvm;
23
24#ifndef LLVM_BUILD_GLOBAL_ISEL
25#error "You shouldn't build this"
26#endif
27
28AMDGPULegalizerInfo::AMDGPULegalizerInfo() {
29 using namespace TargetOpcode;
30
Tom Stellarde0424122017-06-03 01:13:33 +000031 const LLT S1= LLT::scalar(1);
Tom Stellardca166212017-01-30 21:56:46 +000032 const LLT S32 = LLT::scalar(32);
33 const LLT S64 = LLT::scalar(64);
34 const LLT P1 = LLT::pointer(1, 64);
35 const LLT P2 = LLT::pointer(2, 64);
36
Tom Stellarde0424122017-06-03 01:13:33 +000037 // FIXME: i1 operands to intrinsics should always be legal, but other i1
38 // values may not be legal. We need to figure out how to distinguish
39 // between these two scenarios.
40 setAction({G_CONSTANT, S1}, Legal);
Tom Stellarda0d67c72017-05-12 16:46:46 +000041 setAction({G_CONSTANT, S32}, Legal);
Tom Stellardca166212017-01-30 21:56:46 +000042 setAction({G_CONSTANT, S64}, Legal);
43
Tom Stellarddde28a82017-05-26 16:40:03 +000044 setAction({G_FCONSTANT, S32}, Legal);
45
Tom Stellardca166212017-01-30 21:56:46 +000046 setAction({G_GEP, P1}, Legal);
47 setAction({G_GEP, P2}, Legal);
48 setAction({G_GEP, 1, S64}, Legal);
49
50 setAction({G_LOAD, P1}, Legal);
51 setAction({G_LOAD, P2}, Legal);
52 setAction({G_LOAD, S32}, Legal);
53 setAction({G_LOAD, 1, P1}, Legal);
54 setAction({G_LOAD, 1, P2}, Legal);
55
56 setAction({G_STORE, S32}, Legal);
57 setAction({G_STORE, 1, P1}, Legal);
58
59 // FIXME: When RegBankSelect inserts copies, it will only create new
60 // registers with scalar types. This means we can end up with
61 // G_LOAD/G_STORE/G_GEP instruction with scalar types for their pointer
62 // operands. In assert builds, the instruction selector will assert
63 // if it sees a generic instruction which isn't legal, so we need to
64 // tell it that scalar types are legal for pointer operands
65 setAction({G_GEP, S64}, Legal);
66 setAction({G_LOAD, 1, S64}, Legal);
67 setAction({G_STORE, 1, S64}, Legal);
68
69 computeTables();
70}