blob: c3818743705555d5f6cea9881651bdf95f71dba0 [file] [log] [blame]
TDYa127d668a062012-04-13 12:36:57 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "runtime_support_builder_x86.h"
18
19#include "ir_builder.h"
20#include "thread.h"
21
22#include <llvm/DerivedTypes.h>
23#include <llvm/Function.h>
24#include <llvm/InlineAsm.h>
25#include <llvm/Module.h>
26#include <llvm/Type.h>
27
28#include <vector>
29
30using namespace llvm;
31
32namespace art {
33namespace compiler_llvm {
34
35using namespace runtime_support;
36
37
38void RuntimeSupportBuilderX86::TargetOptimizeRuntimeSupport() {
39 {
40 Function* func = GetRuntimeSupportFunction(GetCurrentThread);
41 MakeFunctionInline(func);
42 BasicBlock* basic_block = BasicBlock::Create(context_, "entry", func);
43 irb_.SetInsertPoint(basic_block);
44
45 std::vector<Type*> func_ty_args;
46 func_ty_args.push_back(irb_.getPtrEquivIntTy());
47 FunctionType* func_ty = FunctionType::get(/*Result=*/irb_.getJObjectTy(),
48 /*Params=*/func_ty_args,
49 /*isVarArg=*/false);
50 InlineAsm* get_fp = InlineAsm::get(func_ty, "movl %fs:($1), $0", "=r,r", false);
51 Value* fp = irb_.CreateCall(get_fp, irb_.getPtrEquivInt(Thread::SelfOffset().Int32Value()));
52 irb_.CreateRet(fp);
53 }
54
55 {
56 Function* func = GetRuntimeSupportFunction(SetCurrentThread);
57 MakeFunctionInline(func);
58 BasicBlock* basic_block = BasicBlock::Create(context_, "entry", func);
59 irb_.SetInsertPoint(basic_block);
60 irb_.CreateRetVoid();
61 }
62}
63
64
65} // namespace compiler_llvm
66} // namespace art