2016-11-11 16:27:37 +08:00
|
|
|
//===- ARMLegalizerInfo.cpp --------------------------------------*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
/// This file implements the targeting of the Machinelegalizer class for ARM.
|
|
|
|
/// \todo This should be generated by TableGen.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMLegalizerInfo.h"
|
2017-02-17 19:25:17 +08:00
|
|
|
#include "ARMSubtarget.h"
|
2016-11-11 16:27:37 +08:00
|
|
|
#include "llvm/CodeGen/ValueTypes.h"
|
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
|
|
|
#include "llvm/IR/Type.h"
|
|
|
|
#include "llvm/Target/TargetOpcodes.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
#ifndef LLVM_BUILD_GLOBAL_ISEL
|
|
|
|
#error "You shouldn't build this"
|
|
|
|
#endif
|
|
|
|
|
2017-02-17 19:25:17 +08:00
|
|
|
ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
|
2016-12-16 20:54:46 +08:00
|
|
|
using namespace TargetOpcode;
|
2016-12-19 22:07:56 +08:00
|
|
|
|
2016-12-19 19:26:31 +08:00
|
|
|
const LLT p0 = LLT::pointer(0, 32);
|
2016-12-19 22:07:56 +08:00
|
|
|
|
2017-01-25 16:47:40 +08:00
|
|
|
const LLT s1 = LLT::scalar(1);
|
2016-12-19 22:07:56 +08:00
|
|
|
const LLT s8 = LLT::scalar(8);
|
|
|
|
const LLT s16 = LLT::scalar(16);
|
2016-12-16 20:54:46 +08:00
|
|
|
const LLT s32 = LLT::scalar(32);
|
2017-02-16 17:09:49 +08:00
|
|
|
const LLT s64 = LLT::scalar(64);
|
2016-12-16 20:54:46 +08:00
|
|
|
|
2016-12-19 19:26:31 +08:00
|
|
|
setAction({G_FRAME_INDEX, p0}, Legal);
|
|
|
|
|
2017-02-24 19:28:24 +08:00
|
|
|
for (unsigned Op : {G_LOAD, G_STORE}) {
|
|
|
|
for (auto Ty : {s1, s8, s16, s32, p0})
|
|
|
|
setAction({Op, Ty}, Legal);
|
|
|
|
setAction({Op, 1, p0}, Legal);
|
|
|
|
}
|
2016-12-19 19:26:31 +08:00
|
|
|
|
2017-04-19 15:29:46 +08:00
|
|
|
for (unsigned Op : {G_ADD, G_SUB, G_MUL})
|
2017-04-18 20:35:28 +08:00
|
|
|
for (auto Ty : {s1, s8, s16, s32})
|
|
|
|
setAction({Op, Ty}, Legal);
|
2016-12-16 20:54:46 +08:00
|
|
|
|
2017-04-24 16:20:05 +08:00
|
|
|
for (unsigned Op : {G_SDIV, G_UDIV}) {
|
|
|
|
if (ST.hasDivideInARMMode())
|
|
|
|
setAction({Op, s32}, Legal);
|
|
|
|
else
|
|
|
|
setAction({Op, s32}, Libcall);
|
|
|
|
}
|
|
|
|
|
2017-01-27 09:30:46 +08:00
|
|
|
for (unsigned Op : {G_SEXT, G_ZEXT}) {
|
2017-01-25 16:10:40 +08:00
|
|
|
setAction({Op, s32}, Legal);
|
2017-01-25 16:47:40 +08:00
|
|
|
for (auto Ty : {s1, s8, s16})
|
2017-01-25 16:10:40 +08:00
|
|
|
setAction({Op, 1, Ty}, Legal);
|
|
|
|
}
|
|
|
|
|
2017-02-28 17:02:42 +08:00
|
|
|
setAction({G_GEP, p0}, Legal);
|
|
|
|
setAction({G_GEP, 1, s32}, Legal);
|
|
|
|
|
2017-02-28 19:33:46 +08:00
|
|
|
setAction({G_CONSTANT, s32}, Legal);
|
|
|
|
|
2017-04-07 17:41:39 +08:00
|
|
|
if (!ST.useSoftFloat() && ST.hasVFP2()) {
|
2017-02-17 19:25:17 +08:00
|
|
|
setAction({G_FADD, s32}, Legal);
|
|
|
|
setAction({G_FADD, s64}, Legal);
|
|
|
|
|
|
|
|
setAction({G_LOAD, s64}, Legal);
|
2017-02-24 19:28:24 +08:00
|
|
|
setAction({G_STORE, s64}, Legal);
|
2017-04-11 18:52:34 +08:00
|
|
|
} else {
|
|
|
|
for (auto Ty : {s32, s64})
|
|
|
|
setAction({G_FADD, Ty}, Libcall);
|
2017-02-17 19:25:17 +08:00
|
|
|
}
|
2017-02-08 21:23:04 +08:00
|
|
|
|
2017-04-10 17:27:39 +08:00
|
|
|
for (unsigned Op : {G_FREM, G_FPOW})
|
|
|
|
for (auto Ty : {s32, s64})
|
|
|
|
setAction({Op, Ty}, Libcall);
|
2017-04-07 17:41:39 +08:00
|
|
|
|
2016-11-11 16:27:37 +08:00
|
|
|
computeTables();
|
|
|
|
}
|