]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Merge ^/head r318380 through r318559.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / AMDGPULegalizerInfo.cpp
1 //===- 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
22 using namespace llvm;
23
24 #ifndef LLVM_BUILD_GLOBAL_ISEL
25 #error "You shouldn't build this"
26 #endif
27
28 AMDGPULegalizerInfo::AMDGPULegalizerInfo() {
29   using namespace TargetOpcode;
30
31   const LLT S32 = LLT::scalar(32);
32   const LLT S64 = LLT::scalar(64);
33   const LLT P1 = LLT::pointer(1, 64);
34   const LLT P2 = LLT::pointer(2, 64);
35
36   setAction({G_CONSTANT, S32}, Legal);
37   setAction({G_CONSTANT, S64}, Legal);
38
39   setAction({G_GEP, P1}, Legal);
40   setAction({G_GEP, P2}, Legal);
41   setAction({G_GEP, 1, S64}, Legal);
42
43   setAction({G_LOAD, P1}, Legal);
44   setAction({G_LOAD, P2}, Legal);
45   setAction({G_LOAD, S32}, Legal);
46   setAction({G_LOAD, 1, P1}, Legal);
47   setAction({G_LOAD, 1, P2}, Legal);
48
49   setAction({G_STORE, S32}, Legal);
50   setAction({G_STORE, 1, P1}, Legal);
51
52   // FIXME: When RegBankSelect inserts copies, it will only create new
53   // registers with scalar types.  This means we can end up with
54   // G_LOAD/G_STORE/G_GEP instruction with scalar types for their pointer
55   // operands.  In assert builds, the instruction selector will assert
56   // if it sees a generic instruction which isn't legal, so we need to
57   // tell it that scalar types are legal for pointer operands
58   setAction({G_GEP, S64}, Legal);
59   setAction({G_LOAD, 1, S64}, Legal);
60   setAction({G_STORE, 1, S64}, Legal);
61
62   computeTables();
63 }