]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ABI.h
Update llvm, clang and lldb to release_38 branch r260756.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / ABI.h
1 //===-- ABI.h ---------------------------------------------------*- 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
10 #ifndef liblldb_ABI_h_
11 #define liblldb_ABI_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/Error.h"
18 #include "lldb/Core/PluginInterface.h"
19 #include "lldb/lldb-private.h"
20
21 #include "llvm/ADT/ArrayRef.h"
22
23 // forward define the llvm::Type class
24 namespace llvm { class Type; }
25
26 namespace lldb_private {
27
28 class ABI :
29     public PluginInterface
30 {
31 public:
32     
33     struct CallArgument
34     {
35         enum eType
36         {
37             HostPointer = 0,        /* pointer to host data */
38             TargetValue ,           /* value is on the target or literal */
39         };
40         eType  type;                /* value of eType */
41         size_t size;                /* size in bytes of this argument */
42
43         lldb::addr_t  value;                    /* literal value */
44         std::unique_ptr<uint8_t[]> data_ap;     /* host data pointer */
45     };
46
47     ~ABI() override;
48
49     virtual size_t
50     GetRedZoneSize () const = 0;
51     
52     virtual bool
53     PrepareTrivialCall ( lldb_private::Thread &thread, 
54                          lldb::addr_t sp,
55                          lldb::addr_t functionAddress,
56                          lldb::addr_t returnAddress, 
57                          llvm::ArrayRef<lldb::addr_t> args) const = 0;
58
59     // Prepare trivial call used from ThreadPlanFunctionCallUsingABI
60     // AD:
61     //  . Because i don't want to change other ABI's this is not declared pure virtual.
62     //    The dummy implementation will simply fail.  Only HexagonABI will currently
63     //    use this method.
64     //  . Two PrepareTrivialCall's is not good design so perhaps this should be combined.
65     //
66     virtual bool
67     PrepareTrivialCall ( lldb_private::Thread &thread, 
68                          lldb::addr_t sp,
69                          lldb::addr_t functionAddress,
70                          lldb::addr_t returnAddress,
71                          llvm::Type &prototype,
72                          llvm::ArrayRef<CallArgument> args) const;
73
74     virtual bool
75     GetArgumentValues (Thread &thread,
76                        ValueList &values) const = 0;
77     
78     lldb::ValueObjectSP
79     GetReturnValueObject (Thread &thread,
80                           CompilerType &type,
81                           bool persistent = true) const;
82     
83     // specialized to work with llvm IR types
84     lldb::ValueObjectSP
85     GetReturnValueObject (Thread &thread,
86                           llvm::Type &type,
87                           bool persistent = true) const;
88     
89     // Set the Return value object in the current frame as though a function with 
90     virtual Error
91     SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) = 0;
92
93 protected:    
94     // This is the method the ABI will call to actually calculate the return value.
95     // Don't put it in a persistent value object, that will be done by the ABI::GetReturnValueObject.
96     virtual lldb::ValueObjectSP
97     GetReturnValueObjectImpl (Thread &thread, CompilerType &ast_type) const = 0;
98     
99     // specialized to work with llvm IR types
100     virtual lldb::ValueObjectSP
101     GetReturnValueObjectImpl( Thread &thread, llvm::Type &ir_type ) const;
102
103 public:
104     virtual bool
105     CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) = 0;
106
107     virtual bool
108     CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) = 0;
109
110     virtual bool
111     RegisterIsVolatile (const RegisterInfo *reg_info) = 0;
112
113     // Should take a look at a call frame address (CFA) which is just the stack
114     // pointer value upon entry to a function. ABIs usually impose alignment
115     // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed.
116     // This function should return true if "cfa" is valid call frame address for
117     // the ABI, and false otherwise. This is used by the generic stack frame unwinding
118     // code to help determine when a stack ends.
119     virtual bool
120     CallFrameAddressIsValid (lldb::addr_t cfa) = 0;
121
122     // Validates a possible PC value and returns true if an opcode can be at "pc".
123     virtual bool
124     CodeAddressIsValid (lldb::addr_t pc) = 0;    
125
126     virtual lldb::addr_t
127     FixCodeAddress (lldb::addr_t pc)
128     {
129         // Some targets might use bits in a code address to indicate
130         // a mode switch. ARM uses bit zero to signify a code address is
131         // thumb, so any ARM ABI plug-ins would strip those bits.
132         return pc;
133     }
134
135     virtual const RegisterInfo *
136     GetRegisterInfoArray (uint32_t &count) = 0;
137
138     bool
139     GetRegisterInfoByName (const ConstString &name, RegisterInfo &info);
140
141     bool
142     GetRegisterInfoByKind (lldb::RegisterKind reg_kind, 
143                            uint32_t reg_num, 
144                            RegisterInfo &info);
145
146     static lldb::ABISP
147     FindPlugin (const ArchSpec &arch);
148     
149 protected:
150
151     //------------------------------------------------------------------
152     // Classes that inherit from ABI can see and modify these
153     //------------------------------------------------------------------
154     ABI();
155
156 private:
157
158     DISALLOW_COPY_AND_ASSIGN (ABI);
159 };
160
161 } // namespace lldb_private
162
163 #endif // liblldb_ABI_h_