51 protected: |
51 protected: |
52 SharkCodeBuffer* code_buffer() const { |
52 SharkCodeBuffer* code_buffer() const { |
53 return _code_buffer; |
53 return _code_buffer; |
54 } |
54 } |
55 |
55 |
|
56 public: |
|
57 llvm::LoadInst* CreateAtomicLoad(llvm::Value* ptr, |
|
58 unsigned align = HeapWordSize, |
|
59 llvm::AtomicOrdering ordering = llvm::SequentiallyConsistent, |
|
60 llvm::SynchronizationScope synchScope = llvm::CrossThread, |
|
61 bool isVolatile = true, |
|
62 const char *name = ""); |
|
63 llvm::StoreInst* CreateAtomicStore(llvm::Value *val, |
|
64 llvm::Value *ptr, |
|
65 unsigned align = HeapWordSize, |
|
66 llvm::AtomicOrdering ordering = llvm::SequentiallyConsistent, |
|
67 llvm::SynchronizationScope SynchScope = llvm::CrossThread, |
|
68 bool isVolatile = true, |
|
69 const char *name = ""); |
|
70 |
56 // Helpers for accessing structures. |
71 // Helpers for accessing structures. |
57 public: |
72 public: |
58 llvm::Value* CreateAddressOfStructEntry(llvm::Value* base, |
73 llvm::Value* CreateAddressOfStructEntry(llvm::Value* base, |
59 ByteSize offset, |
74 ByteSize offset, |
60 const llvm::Type* type, |
75 llvm::Type* type, |
61 const char *name = ""); |
76 const char *name = ""); |
62 llvm::LoadInst* CreateValueOfStructEntry(llvm::Value* base, |
77 llvm::LoadInst* CreateValueOfStructEntry(llvm::Value* base, |
63 ByteSize offset, |
78 ByteSize offset, |
64 const llvm::Type* type, |
79 llvm::Type* type, |
65 const char *name = ""); |
80 const char *name = ""); |
66 |
81 |
67 // Helpers for accessing arrays. |
82 // Helpers for accessing arrays. |
68 public: |
83 public: |
69 llvm::LoadInst* CreateArrayLength(llvm::Value* arrayoop); |
84 llvm::LoadInst* CreateArrayLength(llvm::Value* arrayoop); |
70 llvm::Value* CreateArrayAddress(llvm::Value* arrayoop, |
85 llvm::Value* CreateArrayAddress(llvm::Value* arrayoop, |
71 const llvm::Type* element_type, |
86 llvm::Type* element_type, |
72 int element_bytes, |
87 int element_bytes, |
73 ByteSize base_offset, |
88 ByteSize base_offset, |
74 llvm::Value* index, |
89 llvm::Value* index, |
75 const char* name = ""); |
90 const char* name = ""); |
76 llvm::Value* CreateArrayAddress(llvm::Value* arrayoop, |
91 llvm::Value* CreateArrayAddress(llvm::Value* arrayoop, |
83 llvm::Value* index, |
98 llvm::Value* index, |
84 const char* name = ""); |
99 const char* name = ""); |
85 |
100 |
86 // Helpers for creating intrinsics and external functions. |
101 // Helpers for creating intrinsics and external functions. |
87 private: |
102 private: |
88 static const llvm::Type* make_type(char type, bool void_ok); |
103 static llvm::Type* make_type(char type, bool void_ok); |
89 static const llvm::FunctionType* make_ftype(const char* params, |
104 static llvm::FunctionType* make_ftype(const char* params, |
90 const char* ret); |
105 const char* ret); |
91 llvm::Value* make_function(const char* name, |
106 llvm::Value* make_function(const char* name, |
92 const char* params, |
107 const char* params, |
93 const char* ret); |
108 const char* ret); |
94 llvm::Value* make_function(address func, |
109 llvm::Value* make_function(address func, |
163 // access them via the various Create* methods below. |
178 // access them via the various Create* methods below. |
164 private: |
179 private: |
165 llvm::Value* cmpxchg_int(); |
180 llvm::Value* cmpxchg_int(); |
166 llvm::Value* cmpxchg_ptr(); |
181 llvm::Value* cmpxchg_ptr(); |
167 llvm::Value* frame_address(); |
182 llvm::Value* frame_address(); |
168 llvm::Value* memory_barrier(); |
|
169 llvm::Value* memset(); |
183 llvm::Value* memset(); |
170 llvm::Value* unimplemented(); |
184 llvm::Value* unimplemented(); |
171 llvm::Value* should_not_reach_here(); |
185 llvm::Value* should_not_reach_here(); |
172 llvm::Value* dump(); |
186 llvm::Value* dump(); |
173 |
187 |
174 // Public interface to low-level non-VM calls. |
188 // Public interface to low-level non-VM calls. |
175 public: |
189 public: |
176 llvm::CallInst* CreateCmpxchgInt(llvm::Value* exchange_value, |
|
177 llvm::Value* dst, |
|
178 llvm::Value* compare_value); |
|
179 llvm::CallInst* CreateCmpxchgPtr(llvm::Value* exchange_value, |
|
180 llvm::Value* dst, |
|
181 llvm::Value* compare_value); |
|
182 llvm::CallInst* CreateGetFrameAddress(); |
190 llvm::CallInst* CreateGetFrameAddress(); |
183 llvm::CallInst* CreateMemoryBarrier(int flags); |
|
184 llvm::CallInst* CreateMemset(llvm::Value* dst, |
191 llvm::CallInst* CreateMemset(llvm::Value* dst, |
185 llvm::Value* value, |
192 llvm::Value* value, |
186 llvm::Value* len, |
193 llvm::Value* len, |
187 llvm::Value* align); |
194 llvm::Value* align); |
188 llvm::CallInst* CreateUnimplemented(const char* file, int line); |
195 llvm::CallInst* CreateUnimplemented(const char* file, int line); |
189 llvm::CallInst* CreateShouldNotReachHere(const char* file, int line); |
196 llvm::CallInst* CreateShouldNotReachHere(const char* file, int line); |
190 NOT_PRODUCT(llvm::CallInst* CreateDump(llvm::Value* value)); |
197 NOT_PRODUCT(llvm::CallInst* CreateDump(llvm::Value* value)); |
191 |
198 |
192 // Flags for CreateMemoryBarrier. |
|
193 public: |
|
194 enum BarrierFlags { |
|
195 BARRIER_LOADLOAD = 1, |
|
196 BARRIER_LOADSTORE = 2, |
|
197 BARRIER_STORELOAD = 4, |
|
198 BARRIER_STORESTORE = 8 |
|
199 }; |
|
200 |
|
201 // HotSpot memory barriers |
199 // HotSpot memory barriers |
202 public: |
200 public: |
203 void CreateUpdateBarrierSet(BarrierSet* bs, llvm::Value* field); |
201 void CreateUpdateBarrierSet(BarrierSet* bs, llvm::Value* field); |
204 |
202 |
205 // Helpers for accessing the code buffer. |
203 // Helpers for accessing the code buffer. |
207 llvm::Value* code_buffer_address(int offset); |
205 llvm::Value* code_buffer_address(int offset); |
208 llvm::Value* CreateInlineOop(jobject object, const char* name = ""); |
206 llvm::Value* CreateInlineOop(jobject object, const char* name = ""); |
209 llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") { |
207 llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") { |
210 return CreateInlineOop(object->constant_encoding(), name); |
208 return CreateInlineOop(object->constant_encoding(), name); |
211 } |
209 } |
|
210 |
|
211 llvm::Value* CreateInlineMetadata(Metadata* metadata, llvm::PointerType* type, const char* name = ""); |
|
212 llvm::Value* CreateInlineMetadata(ciMetadata* metadata, llvm::PointerType* type, const char* name = "") { |
|
213 return CreateInlineMetadata(metadata->constant_encoding(), type, name); |
|
214 } |
212 llvm::Value* CreateInlineData(void* data, |
215 llvm::Value* CreateInlineData(void* data, |
213 size_t size, |
216 size_t size, |
214 const llvm::Type* type, |
217 llvm::Type* type, |
215 const char* name = ""); |
218 const char* name = ""); |
216 |
219 |
217 // Helpers for creating basic blocks. |
220 // Helpers for creating basic blocks. |
218 // NB don't use unless SharkFunction::CreateBlock is unavailable. |
221 // NB don't use unless SharkFunction::CreateBlock is unavailable. |
219 // XXX these are hacky and should be removed. |
222 // XXX these are hacky and should be removed. |
220 public: |
223 public: |
221 llvm::BasicBlock* GetBlockInsertionPoint() const; |
224 llvm::BasicBlock* GetBlockInsertionPoint() const; |
222 llvm::BasicBlock* CreateBlock(llvm::BasicBlock* ip, |
225 llvm::BasicBlock* CreateBlock(llvm::BasicBlock* ip, |
223 const char* name="") const; |
226 const char* name="") const; |
224 }; |
227 }; |
225 |
228 #endif // SHARE_VM_SHARK_SHARKBUILDER_HPP |
226 #endif // SHARE_VM_SHARK_SHARKBUILDER_HPP |
|