1 | /* |
2 | * Copyright (C) 2017 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "AirPrintSpecial.h" |
28 | |
29 | #if ENABLE(B3_JIT) |
30 | #if ENABLE(MASM_PROBE) |
31 | |
32 | #include "MacroAssemblerPrinter.h" |
33 | |
34 | namespace JSC { namespace B3 { namespace Air { |
35 | |
36 | PrintSpecial::PrintSpecial(Printer::PrintRecordList* list) |
37 | : m_printRecordList(list) |
38 | { |
39 | } |
40 | |
41 | PrintSpecial::~PrintSpecial() |
42 | { |
43 | } |
44 | |
45 | void PrintSpecial::forEachArg(Inst&, const ScopedLambda<Inst::EachArgCallback>&) |
46 | { |
47 | } |
48 | |
49 | bool PrintSpecial::isValid(Inst&) |
50 | { |
51 | return true; |
52 | } |
53 | |
54 | bool PrintSpecial::admitsStack(Inst&, unsigned) |
55 | { |
56 | return false; |
57 | } |
58 | |
59 | bool PrintSpecial::admitsExtendedOffsetAddr(Inst&, unsigned) |
60 | { |
61 | return false; |
62 | } |
63 | |
64 | void PrintSpecial::reportUsedRegisters(Inst&, const RegisterSet&) |
65 | { |
66 | } |
67 | |
68 | CCallHelpers::Jump PrintSpecial::generate(Inst& inst, CCallHelpers& jit, GenerationContext&) |
69 | { |
70 | size_t currentArg = 1; // Skip the PrintSpecial arg. |
71 | for (auto& term : *m_printRecordList) { |
72 | if (term.printer == Printer::printAirArg) { |
73 | const Arg& arg = inst.args[currentArg++]; |
74 | switch (arg.kind()) { |
75 | case Arg::Tmp: |
76 | term = Printer::Printer<MacroAssembler::RegisterID>(arg.gpr()); |
77 | break; |
78 | case Arg::Addr: |
79 | case Arg::ExtendedOffsetAddr: |
80 | term = Printer::Printer<MacroAssembler::Address>(arg.asAddress()); |
81 | break; |
82 | default: |
83 | RELEASE_ASSERT_NOT_REACHED(); |
84 | break; |
85 | } |
86 | } |
87 | } |
88 | jit.print(m_printRecordList); |
89 | return CCallHelpers::Jump(); |
90 | } |
91 | |
92 | RegisterSet PrintSpecial::(Inst&) |
93 | { |
94 | return { }; |
95 | } |
96 | |
97 | RegisterSet PrintSpecial::(Inst&) |
98 | { |
99 | return { }; |
100 | } |
101 | |
102 | void PrintSpecial::dumpImpl(PrintStream& out) const |
103 | { |
104 | out.print("Print" ); |
105 | } |
106 | |
107 | void PrintSpecial::deepDumpImpl(PrintStream& out) const |
108 | { |
109 | out.print("print for debugging logging." ); |
110 | } |
111 | |
112 | } } // namespace B3::Air |
113 | |
114 | namespace Printer { |
115 | |
116 | NO_RETURN void printAirArg(PrintStream&, Context&) |
117 | { |
118 | // This function is only a placeholder to let PrintSpecial::generate() know that |
119 | // the Printer needs to be replaced with one for a register, constant, etc. Hence, |
120 | // this function should never be called. |
121 | RELEASE_ASSERT_NOT_REACHED(); |
122 | } |
123 | |
124 | } // namespace Printer |
125 | |
126 | } // namespace JSC |
127 | |
128 | #endif // ENABLE(MASM_PROBE) |
129 | #endif // ENABLE(B3_JIT) |
130 | |