1 //===- ARMLegalizerInfo.cpp --------------------------------------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// This file implements the targeting of the Machinelegalizer class for ARM.
11 /// \todo This should be generated by TableGen.
12 //===----------------------------------------------------------------------===//
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"
23 #ifndef LLVM_BUILD_GLOBAL_ISEL
24 #error "You shouldn't build this"
27 ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
28 using namespace TargetOpcode;
30 const LLT p0 = LLT::pointer(0, 32);
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);
38 setAction({G_FRAME_INDEX, p0}, Legal);
40 for (unsigned Op : {G_LOAD, G_STORE}) {
41 for (auto Ty : {s1, s8, s16, s32, p0})
42 setAction({Op, Ty}, Legal);
43 setAction({Op, 1, p0}, Legal);
46 for (unsigned Op : {G_ADD, G_SUB, G_MUL})
47 for (auto Ty : {s1, s8, s16, s32})
48 setAction({Op, Ty}, Legal);
50 for (unsigned Op : {G_SEXT, G_ZEXT}) {
51 setAction({Op, s32}, Legal);
52 for (auto Ty : {s1, s8, s16})
53 setAction({Op, 1, Ty}, Legal);
56 setAction({G_GEP, p0}, Legal);
57 setAction({G_GEP, 1, s32}, Legal);
59 setAction({G_CONSTANT, s32}, Legal);
61 if (!ST.useSoftFloat() && ST.hasVFP2()) {
62 setAction({G_FADD, s32}, Legal);
63 setAction({G_FADD, s64}, Legal);
65 setAction({G_LOAD, s64}, Legal);
66 setAction({G_STORE, s64}, Legal);
68 for (auto Ty : {s32, s64})
69 setAction({G_FADD, Ty}, Libcall);
72 for (unsigned Op : {G_FREM, G_FPOW})
73 for (auto Ty : {s32, s64})
74 setAction({Op, Ty}, Libcall);