| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 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" | 
| Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 15 | #include "ARMSubtarget.h" | 
| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 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 |  | 
| Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 27 | ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) { | 
| Diana Picus | 812caee | 2016-12-16 12:54:46 +0000 | [diff] [blame] | 28 | using namespace TargetOpcode; | 
| Diana Picus | 5a72445 | 2016-12-19 14:07:56 +0000 | [diff] [blame] | 29 |  | 
| Diana Picus | 519807f | 2016-12-19 11:26:31 +0000 | [diff] [blame] | 30 | const LLT p0 = LLT::pointer(0, 32); | 
| Diana Picus | 5a72445 | 2016-12-19 14:07:56 +0000 | [diff] [blame] | 31 |  | 
| Diana Picus | d83df5d | 2017-01-25 08:47:40 +0000 | [diff] [blame] | 32 | const LLT s1 = LLT::scalar(1); | 
| Diana Picus | 5a72445 | 2016-12-19 14:07:56 +0000 | [diff] [blame] | 33 | const LLT s8 = LLT::scalar(8); | 
|  | 34 | const LLT s16 = LLT::scalar(16); | 
| Diana Picus | 812caee | 2016-12-16 12:54:46 +0000 | [diff] [blame] | 35 | const LLT s32 = LLT::scalar(32); | 
| Diana Picus | 21c3d8e | 2017-02-16 09:09:49 +0000 | [diff] [blame] | 36 | const LLT s64 = LLT::scalar(64); | 
| Diana Picus | 812caee | 2016-12-16 12:54:46 +0000 | [diff] [blame] | 37 |  | 
| Diana Picus | 519807f | 2016-12-19 11:26:31 +0000 | [diff] [blame] | 38 | setAction({G_FRAME_INDEX, p0}, Legal); | 
|  | 39 |  | 
| Diana Picus | a2b632a | 2017-02-24 11:28:24 +0000 | [diff] [blame] | 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); | 
|  | 44 | } | 
| Diana Picus | 519807f | 2016-12-19 11:26:31 +0000 | [diff] [blame] | 45 |  | 
| Diana Picus | d83df5d | 2017-01-25 08:47:40 +0000 | [diff] [blame] | 46 | for (auto Ty : {s1, s8, s16, s32}) | 
| Diana Picus | 5a72445 | 2016-12-19 14:07:56 +0000 | [diff] [blame] | 47 | setAction({G_ADD, Ty}, Legal); | 
| Diana Picus | 812caee | 2016-12-16 12:54:46 +0000 | [diff] [blame] | 48 |  | 
| Quentin Colombet | 89dbea0 | 2017-01-27 01:30:46 +0000 | [diff] [blame] | 49 | for (unsigned Op : {G_SEXT, G_ZEXT}) { | 
| Diana Picus | 8b6c6be | 2017-01-25 08:10:40 +0000 | [diff] [blame] | 50 | setAction({Op, s32}, Legal); | 
| Diana Picus | d83df5d | 2017-01-25 08:47:40 +0000 | [diff] [blame] | 51 | for (auto Ty : {s1, s8, s16}) | 
| Diana Picus | 8b6c6be | 2017-01-25 08:10:40 +0000 | [diff] [blame] | 52 | setAction({Op, 1, Ty}, Legal); | 
|  | 53 | } | 
|  | 54 |  | 
| Diana Picus | 8598b17 | 2017-02-28 09:02:42 +0000 | [diff] [blame] | 55 | setAction({G_GEP, p0}, Legal); | 
|  | 56 | setAction({G_GEP, 1, s32}, Legal); | 
|  | 57 |  | 
| Diana Picus | e6beac6 | 2017-02-28 11:33:46 +0000 | [diff] [blame] | 58 | setAction({G_CONSTANT, s32}, Legal); | 
|  | 59 |  | 
| Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 60 | if (ST.hasVFP2()) { | 
|  | 61 | setAction({G_FADD, s32}, Legal); | 
|  | 62 | setAction({G_FADD, s64}, Legal); | 
|  | 63 |  | 
|  | 64 | setAction({G_LOAD, s64}, Legal); | 
| Diana Picus | a2b632a | 2017-02-24 11:28:24 +0000 | [diff] [blame] | 65 | setAction({G_STORE, s64}, Legal); | 
| Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 66 | } | 
| Diana Picus | 4fa83c0 | 2017-02-08 13:23:04 +0000 | [diff] [blame] | 67 |  | 
| Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 68 | computeTables(); | 
|  | 69 | } |