1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: IEMAllN8vePython.py 101370 2023-10-06 01:23:09Z vboxsync $
|
---|
4 | # pylint: disable=invalid-name
|
---|
5 |
|
---|
6 | """
|
---|
7 | Native recompiler side-kick for IEMAllThrdPython.py.
|
---|
8 |
|
---|
9 | Analyzes the each threaded function variant to see if we can we're able to
|
---|
10 | recompile it, then provides modifies MC block code for doing so.
|
---|
11 | """
|
---|
12 |
|
---|
13 | from __future__ import print_function;
|
---|
14 |
|
---|
15 | __copyright__ = \
|
---|
16 | """
|
---|
17 | Copyright (C) 2023 Oracle and/or its affiliates.
|
---|
18 |
|
---|
19 | This file is part of VirtualBox base platform packages, as
|
---|
20 | available from https://www.alldomusa.eu.org.
|
---|
21 |
|
---|
22 | This program is free software; you can redistribute it and/or
|
---|
23 | modify it under the terms of the GNU General Public License
|
---|
24 | as published by the Free Software Foundation, in version 3 of the
|
---|
25 | License.
|
---|
26 |
|
---|
27 | This program is distributed in the hope that it will be useful, but
|
---|
28 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
29 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
30 | General Public License for more details.
|
---|
31 |
|
---|
32 | You should have received a copy of the GNU General Public License
|
---|
33 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
34 |
|
---|
35 | SPDX-License-Identifier: GPL-3.0-only
|
---|
36 | """
|
---|
37 | __version__ = "$Revision: 101370 $"
|
---|
38 |
|
---|
39 | # Standard python imports:
|
---|
40 | #import sys;
|
---|
41 |
|
---|
42 | # Out python imports:
|
---|
43 | import IEMAllInstPython as iai;
|
---|
44 |
|
---|
45 |
|
---|
46 | class NativeRecompFunctionVariation(object):
|
---|
47 | """
|
---|
48 | Class that deals with transforming a threaded function variation into a
|
---|
49 | native recompiler function.
|
---|
50 |
|
---|
51 | This base class doesn't do any transforming and just renders the same
|
---|
52 | code as for the threaded function.
|
---|
53 | """
|
---|
54 |
|
---|
55 | def __init__(self, oVariation, sHostArch):
|
---|
56 | self.oVariation = oVariation # type: ThreadedFunctionVariation
|
---|
57 | self.sHostArch = sHostArch;
|
---|
58 |
|
---|
59 | def isRecompilable(self):
|
---|
60 | """
|
---|
61 | Predicate that returns whether the variant can be recompiled natively
|
---|
62 | (for the selected host architecture).
|
---|
63 | """
|
---|
64 | return True;
|
---|
65 |
|
---|
66 | def renderCode(self, cchIndent):
|
---|
67 | """
|
---|
68 | Returns the native recompiler function body for this threaded variant.
|
---|
69 | """
|
---|
70 | aoStmts = self.oVariation.aoStmtsForThreadedFunction # type: list(McStmt)
|
---|
71 | return iai.McStmt.renderCodeForList(aoStmts, cchIndent);
|
---|
72 |
|
---|
73 |
|
---|
74 |
|
---|
75 | def analyzeVariantForNativeRecomp(oVariation,
|
---|
76 | sHostArch): # type: (ThreadedFunctionVariation, str) -> NativeRecompFunctionVariation
|
---|
77 | """
|
---|
78 | This function analyzes the threaded function variant and returns an
|
---|
79 | NativeRecompFunctionVariation instance for it, unless it's not
|
---|
80 | possible to recompile at present.
|
---|
81 |
|
---|
82 | Returns NativeRecompFunctionVariation or None.
|
---|
83 | """
|
---|
84 |
|
---|
85 | #
|
---|
86 | # Analyze the statements.
|
---|
87 | #
|
---|
88 | aoStmts = oVariation.aoStmtsForThreadedFunction # type: list(McStmt)
|
---|
89 |
|
---|
90 | # The simplest case are the IEM_MC_DEFER_TO_CIMPL_*_RET_THREADED ones, just pass them thru:
|
---|
91 | if ( len(aoStmts) == 1
|
---|
92 | and aoStmts[0].sName.startswith('IEM_MC_DEFER_TO_CIMPL_')
|
---|
93 | and aoStmts[0].sName.endswith('_RET_THREADED')):
|
---|
94 | return NativeRecompFunctionVariation(oVariation, sHostArch);
|
---|
95 |
|
---|
96 | return None;
|
---|