-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathSignature.h
81 lines (66 loc) · 2.03 KB
/
Signature.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//===--- Signature.h - An IR function signature -----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the Signature type, which encapsulates all the
// information necessary to call a function value correctly.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_IRGEN_SIGNATURE_H
#define SWIFT_IRGEN_SIGNATURE_H
#include "llvm/IR/Attributes.h"
#include "swift/AST/Types.h"
namespace llvm {
class FunctionType;
}
namespace clang {
namespace CodeGen {
class CGFunctionInfo;
}
}
namespace swift {
class Identifier;
enum class SILFunctionTypeRepresentation : uint8_t;
class SILType;
namespace irgen {
/// An encapsulation of different foreign calling-convention lowering
/// information we might have. Should be interpreted according to the
/// abstract CC of the formal function type.
class ForeignFunctionInfo {
public:
const clang::CodeGen::CGFunctionInfo *ClangInfo = nullptr;
};
/// A signature represents something which can actually be called.
class Signature {
llvm::FunctionType *Type = nullptr;
llvm::AttributeSet Attributes;
ForeignFunctionInfo ForeignInfo;
public:
bool isValid() const {
return Type != nullptr;
}
static Signature get(IRGenModule &IGM, CanSILFunctionType formalType);
llvm::FunctionType *getType() const {
assert(isValid());
return Type;
}
llvm::AttributeSet getAttributes() const {
assert(isValid());
return Attributes;
}
const ForeignFunctionInfo &getForeignInfo() const {
assert(isValid());
return ForeignInfo;
}
};
} // end namespace irgen
} // end namespace swift
#endif