blob: d5bf1dbf386b5eedc5b0a0776e24c748341858ef [file] [log] [blame]
Tim Northover33b07d62016-07-22 20:03:43 +00001//===- AArch64MachineLegalizer.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/// AArch64.
12/// \todo This should be generated by TableGen.
13//===----------------------------------------------------------------------===//
14
15#include "AArch64MachineLegalizer.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
21using namespace llvm;
22
23#ifndef LLVM_BUILD_GLOBAL_ISEL
24#error "You shouldn't build this"
25#endif
26
27AArch64MachineLegalizer::AArch64MachineLegalizer() {
Ahmed Bougachaad30db32016-08-02 15:10:28 +000028 using namespace TargetOpcode;
Tim Northoverea904f92016-08-19 22:40:00 +000029 const LLT s1 = LLT::scalar(1);
Tim Northover9656f142016-08-04 20:54:13 +000030 const LLT s8 = LLT::scalar(8);
31 const LLT s16 = LLT::scalar(16);
Ahmed Bougachaad30db32016-08-02 15:10:28 +000032 const LLT s32 = LLT::scalar(32);
33 const LLT s64 = LLT::scalar(64);
34 const LLT v2s32 = LLT::vector(2, 32);
35 const LLT v4s32 = LLT::vector(4, 32);
36 const LLT v2s64 = LLT::vector(2, 64);
37
Tim Northover61c16142016-08-04 21:39:49 +000038 for (auto BinOp : {G_ADD, G_SUB, G_MUL, G_AND, G_OR, G_XOR}) {
Ahmed Bougachaad30db32016-08-02 15:10:28 +000039 for (auto Ty : {s32, s64, v2s32, v4s32, v2s64})
40 setAction(BinOp, Ty, Legal);
41
Tim Northover9656f142016-08-04 20:54:13 +000042 for (auto Ty : {s8, s16})
43 setAction(BinOp, Ty, WidenScalar);
44 }
45
Ahmed Bougacha1d0560b2016-08-18 15:17:13 +000046 for (auto BinOp : {G_SHL, G_LSHR, G_ASHR, G_SDIV, G_UDIV})
Ahmed Bougacha2ac5bf92016-08-16 14:02:47 +000047 for (auto Ty : {s32, s64})
48 setAction(BinOp, Ty, Legal);
49
Ahmed Bougacha33e19fe2016-08-18 16:05:11 +000050 for (auto BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
51 for (auto Ty : {s32, s64})
52 setAction(BinOp, Ty, Legal);
53
Tim Northover3c73e362016-08-23 18:20:09 +000054 for (auto MemOp : {G_LOAD, G_STORE}) {
55 for (auto Ty : {s8, s16, s32, s64})
Ahmed Bougachaad30db32016-08-02 15:10:28 +000056 setAction(MemOp, Ty, Legal);
57
Tim Northover3c73e362016-08-23 18:20:09 +000058 setAction(MemOp, s1, WidenScalar);
59 }
60
Tim Northoverea904f92016-08-19 22:40:00 +000061 for (auto Ty : {s32, s64}) {
62 setAction(TargetOpcode::G_CONSTANT, Ty, Legal);
63 setAction(TargetOpcode::G_FCONSTANT, Ty, Legal);
64 }
65
66 for (auto Ty : {s1, s8, s16})
67 setAction(TargetOpcode::G_CONSTANT, Ty, WidenScalar);
68
Tim Northovera11be042016-08-19 22:40:08 +000069 setAction(TargetOpcode::G_FCONSTANT, s16, WidenScalar);
Tim Northover9656f142016-08-04 20:54:13 +000070
Ahmed Bougachaad30db32016-08-02 15:10:28 +000071 setAction(G_BR, LLT::unsized(), Legal);
72
Ahmed Bougacha0306b5e2016-08-16 14:02:42 +000073 setAction(G_FRAME_INDEX, LLT::pointer(0), Legal);
74
Tim Northover33b07d62016-07-22 20:03:43 +000075 computeTables();
76}