xref: /llvm-project/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp (revision c21d1e5d94dcab9597fa761117806de8f2b35e42)
1 //===- ARMLegalizerInfo.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 ARM.
11 /// \todo This should be generated by TableGen.
12 //===----------------------------------------------------------------------===//
13 
14 #include "ARMLegalizerInfo.h"
15 #include "ARMSubtarget.h"
16 #include "llvm/CodeGen/ValueTypes.h"
17 #include "llvm/IR/DerivedTypes.h"
18 #include "llvm/IR/Type.h"
19 #include "llvm/Target/TargetOpcodes.h"
20 
21 using namespace llvm;
22 
23 #ifndef LLVM_BUILD_GLOBAL_ISEL
24 #error "You shouldn't build this"
25 #endif
26 
27 ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
28   using namespace TargetOpcode;
29 
30   const LLT p0 = LLT::pointer(0, 32);
31 
32   const LLT s1 = LLT::scalar(1);
33   const LLT s8 = LLT::scalar(8);
34   const LLT s16 = LLT::scalar(16);
35   const LLT s32 = LLT::scalar(32);
36   const LLT s64 = LLT::scalar(64);
37 
38   setAction({G_FRAME_INDEX, p0}, Legal);
39 
40   for (auto Ty : {s1, s8, s16, s32, p0})
41     setAction({G_LOAD, Ty}, Legal);
42   setAction({G_LOAD, 1, p0}, Legal);
43 
44   for (auto Ty : {s1, s8, s16, s32})
45     setAction({G_ADD, Ty}, Legal);
46 
47   for (unsigned Op : {G_SEXT, G_ZEXT}) {
48     setAction({Op, s32}, Legal);
49     for (auto Ty : {s1, s8, s16})
50       setAction({Op, 1, Ty}, Legal);
51   }
52 
53   if (ST.hasVFP2()) {
54     setAction({G_FADD, s32}, Legal);
55     setAction({G_FADD, s64}, Legal);
56 
57     setAction({G_LOAD, s64}, Legal);
58   }
59 
60   computeTables();
61 }
62