clang 20.0.0git
MSP430.cpp
Go to the documentation of this file.
1//===- MSP430.cpp ---------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "ABIInfoImpl.h"
10#include "TargetInfo.h"
11
12using namespace clang;
13using namespace clang::CodeGen;
14
15//===----------------------------------------------------------------------===//
16// MSP430 ABI Implementation
17//===----------------------------------------------------------------------===//
18
19namespace {
20
21class MSP430ABIInfo : public DefaultABIInfo {
22 static ABIArgInfo complexArgInfo() {
24 Info.setCanBeFlattened(false);
25 return Info;
26 }
27
28public:
29 MSP430ABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
30
32 if (RetTy->isAnyComplexType())
33 return complexArgInfo();
34
36 }
37
39 if (RetTy->isAnyComplexType())
40 return complexArgInfo();
41
43 }
44
45 // Just copy the original implementations because
46 // DefaultABIInfo::classify{Return,Argument}Type() are not virtual
47 void computeInfo(CGFunctionInfo &FI) const override {
50 for (auto &I : FI.arguments())
51 I.info = classifyArgumentType(I.type);
52 }
53
54 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
55 AggValueSlot Slot) const override {
56 return CGF.EmitLoadOfAnyValue(
58 EmitVAArgInstr(CGF, VAListAddr, Ty, classifyArgumentType(Ty)), Ty),
59 Slot);
60 }
61};
62
63class MSP430TargetCodeGenInfo : public TargetCodeGenInfo {
64public:
65 MSP430TargetCodeGenInfo(CodeGenTypes &CGT)
66 : TargetCodeGenInfo(std::make_unique<MSP430ABIInfo>(CGT)) {}
67 void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
68 CodeGen::CodeGenModule &M) const override;
69};
70
71}
72
73void MSP430TargetCodeGenInfo::setTargetAttributes(
74 const Decl *D, llvm::GlobalValue *GV,