1 //===-- llvm/ParameterAttributes.h - Container for ParamAttrs ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the simple types necessary to represent the parameter
11 // attributes associated with functions and their calls.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_PARAMETER_ATTRIBUTES_H
16 #define LLVM_PARAMETER_ATTRIBUTES_H
18 #include "llvm/Support/DataTypes.h"
26 /// Function parameters and results can have attributes to indicate how they
27 /// should be treated by optimizations and code generation. This enumeration
28 /// lists the attributes that can be associated with parameters or function
30 /// @brief Function parameter attributes.
32 /// @brief A more friendly way to reference the attributes.
33 typedef uint32_t Attributes;
35 const Attributes None = 0; ///< No attributes have been set
36 const Attributes ZExt = 1<<0; ///< Zero extended before/after call
37 const Attributes SExt = 1<<1; ///< Sign extended before/after call
38 const Attributes NoReturn = 1<<2; ///< Mark the function as not returning
39 const Attributes InReg = 1<<3; ///< Force argument to be passed in register
40 const Attributes StructRet = 1<<4; ///< Hidden pointer to structure to return
41 const Attributes NoUnwind = 1<<5; ///< Function doesn't unwind stack
42 const Attributes NoAlias = 1<<6; ///< Considered to not alias after call
43 const Attributes ByVal = 1<<7; ///< Pass structure by value
44 const Attributes Nest = 1<<8; ///< Nested function static chain
45 const Attributes ReadNone = 1<<9; ///< Function does not access memory
46 const Attributes ReadOnly = 1<<10; ///< Function only reads from memory
47 const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
48 // 0 = unknown, else in clear (not log)
50 /// @brief Attributes that only apply to function parameters.
51 const Attributes ParameterOnly = ByVal | InReg | Nest | StructRet;
53 /// @brief Attributes that only apply to function return values.
54 const Attributes ReturnOnly = NoReturn | NoUnwind | ReadNone | ReadOnly;
56 /// @brief Parameter attributes that do not apply to vararg call arguments.
57 const Attributes VarArgsIncompatible = StructRet;
59 /// @brief Attributes that are mutually incompatible.
60 const Attributes MutuallyIncompatible[3] = {
61 ByVal | InReg | Nest | StructRet,
66 /// @brief Which attributes cannot be applied to a type.
67 Attributes typeIncompatible (const Type *Ty);
69 /// This turns an int alignment (a power of 2, normally) into the
70 /// form used internally in ParameterAttributes.
71 ParamAttr::Attributes inline constructAlignmentFromInt(uint32_t i) {
75 } // end namespace ParamAttr
77 /// @brief A more friendly way to reference the attributes.
78 typedef ParamAttr::Attributes ParameterAttributes;
80 /// This is just a pair of values to associate a set of parameter attributes
81 /// with a parameter index.
82 /// @brief ParameterAttributes with a parameter index.
83 struct ParamAttrsWithIndex {
84 ParameterAttributes attrs; ///< The attributes that are set, or'd together
85 uint16_t index; ///< Index of the parameter for which the attributes apply
87 static ParamAttrsWithIndex get(uint16_t idx, ParameterAttributes attrs) {
88 ParamAttrsWithIndex P;
95 } // End llvm namespace