1// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4// Class for intrinsifying functions.
5
6#ifndef RUNTIME_VM_COMPILER_ASM_INTRINSIFIER_H_
7#define RUNTIME_VM_COMPILER_ASM_INTRINSIFIER_H_
8
9#if defined(DART_PRECOMPILED_RUNTIME)
10#error "AOT runtime should not use compiler sources (including header files)"
11#endif // defined(DART_PRECOMPILED_RUNTIME)
12
13#include "vm/allocation.h"
14#include "vm/compiler/recognized_methods_list.h"
15
16namespace dart {
17
18// Forward declarations.
19class FlowGraphCompiler;
20class Function;
21class TargetEntryInstr;
22class ParsedFunction;
23class FlowGraph;
24
25namespace compiler {
26class Assembler;
27class Label;
28
29class AsmIntrinsifier : public AllStatic {
30 public:
31 static intptr_t ParameterSlotFromSp();
32
33 static void IntrinsicCallPrologue(Assembler* assembler);
34 static void IntrinsicCallEpilogue(Assembler* assembler);
35
36 private:
37 friend class Intrinsifier;
38
39 // The "_A" value used in the intrinsification of
40 // `runtime/lib/math_patch.dart:_Random._nextState()`
41 static const int64_t kRandomAValue = 0xffffda61;
42
43 static bool CanIntrinsify(const Function& function);
44
45#define DECLARE_FUNCTION(class_name, function_name, enum_name, fp) \
46 static void enum_name(Assembler* assembler, Label* normal_ir_body);
47 ALL_INTRINSICS_LIST(DECLARE_FUNCTION)
48
49#undef DECLARE_FUNCTION
50
51 static void IntrinsifyRegExpExecuteMatch(Assembler* assembler,
52 Label* normal_ir_body,
53 bool sticky);
54};
55
56} // namespace compiler
57} // namespace dart
58
59#endif // RUNTIME_VM_COMPILER_ASM_INTRINSIFIER_H_
60