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 "llvm/CodeGen/ValueTypes.h"
16 #include "llvm/IR/DerivedTypes.h"
17 #include "llvm/IR/Type.h"
18 #include "llvm/Target/TargetOpcodes.h"
19 
20 using namespace llvm;
21 
22 #ifndef LLVM_BUILD_GLOBAL_ISEL
23 #error "You shouldn't build this"
24 #endif
25 
26 ARMLegalizerInfo::ARMLegalizerInfo() {
27   using namespace TargetOpcode;
28 
29   const LLT p0 = LLT::pointer(0, 32);
30 
31   const LLT s1 = LLT::scalar(1);
32   const LLT s8 = LLT::scalar(8);
33   const LLT s16 = LLT::scalar(16);
34   const LLT s32 = LLT::scalar(32);
35 
36   setAction({G_FRAME_INDEX, p0}, Legal);
37 
38   for (auto Ty : {s1, s8, s16, s32, p0})
39     setAction({G_LOAD, Ty}, Legal);
40   setAction({G_LOAD, 1, p0}, Legal);
41 
42   for (auto Ty : {s1, s8, s16, s32})
43     setAction({G_ADD, Ty}, Legal);
44 
45   for (unsigned Op : {G_SEXT, G_ZEXT}) {
46     setAction({Op, s32}, Legal);
47     for (auto Ty : {s1, s8, s16})
48       setAction({Op, 1, Ty}, Legal);
49   }
50 
51   // FIXME: This is a bit sloppy, but for now we'll just rely on the instruction
52   // selector to complain if it doesn't support floating point.
53   setAction({G_FADD, s32}, Legal);
54 
55   computeTables();
56 }
57