blob: 3f05d56a9a5aac18f485992732c2df0ecb8fc7a4 (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/machine-graph.h"
#include "src/codegen/external-reference.h"
#include "src/compiler/node-properties.h"
namespace v8 {
namespace internal {
namespace compiler {
Node* MachineGraph::Int32Constant(int32_t value) {
Node** loc = cache_.FindInt32Constant(value);
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->Int32Constant(value));
}
return *loc;
}
Node* MachineGraph::Int64Constant(int64_t value) {
Node** loc = cache_.FindInt64Constant(value);
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->Int64Constant(value));
}
return *loc;
}
Node* MachineGraph::IntPtrConstant(intptr_t value) {
return machine()->Is32() ? Int32Constant(static_cast<int32_t>(value))
: Int64Constant(static_cast<int64_t>(value));
}
Node* MachineGraph::RelocatableInt32Constant(int32_t value,
RelocInfo::Mode rmode) {
Node** loc = cache_.FindRelocatableInt32Constant(
value, static_cast<RelocInfoMode>(rmode));
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->RelocatableInt32Constant(value, rmode));
}
return *loc;
}
Node* MachineGraph::RelocatableInt64Constant(int64_t value,
RelocInfo::Mode rmode) {
Node** loc = cache_.FindRelocatableInt64Constant(
value, static_cast<RelocInfoMode>(rmode));
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->RelocatableInt64Constant(value, rmode));
}
return *loc;
}
Node* MachineGraph::RelocatableIntPtrConstant(intptr_t value,
RelocInfo::Mode rmode) {
return kSystemPointerSize == 8
? RelocatableInt64Constant(value, rmode)
: RelocatableInt32Constant(static_cast<int>(value), rmode);
}
Node* MachineGraph::Float32Constant(float value) {
Node** loc = cache_.FindFloat32Constant(value);
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->Float32Constant(value));
}
return *loc;
}
Node* MachineGraph::Float64Constant(double value) {
Node** loc = cache_.FindFloat64Constant(value);
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->Float64Constant(value));
}
return *loc;
}
Node* MachineGraph::PointerConstant(intptr_t value) {
Node** loc = cache_.FindPointerConstant(value);
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->PointerConstant(value));
}
return *loc;
}
Node* MachineGraph::ExternalConstant(ExternalReference reference) {
Node** loc = cache_.FindExternalConstant(reference);
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->ExternalConstant(reference));
}
return *loc;
}
Node* MachineGraph::ExternalConstant(Runtime::FunctionId function_id) {
return ExternalConstant(ExternalReference::Create(function_id));
}
} // namespace compiler
} // namespace internal
} // namespace v8
|