Path: blob/master/runtime/compiler/x/amd64/codegen/J9CodeGenerator.cpp
6004 views
/*******************************************************************************1* Copyright (c) 2000, 2020 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#include "codegen/CodeGenerator.hpp"23#include "codegen/CodeGenerator_inlines.hpp"24#include "codegen/X86PrivateLinkage.hpp"25#include "compile/Compilation.hpp"26#include "x/codegen/X86HelperLinkage.hpp"27#include "codegen/AMD64PrivateLinkage.hpp"28#include "codegen/AMD64JNILinkage.hpp"29#include "codegen/AMD64J9SystemLinkage.hpp"30#include "codegen/Linkage_inlines.hpp"31#include "il/Node.hpp"32#include "il/Node_inlines.hpp"33#include "env/CompilerEnv.hpp"3435void36J9::X86::AMD64::CodeGenerator::initialize()37{38self()->J9::X86::CodeGenerator::initialize();39}404142TR::Linkage *43J9::X86::AMD64::CodeGenerator::createLinkage(TR_LinkageConventions lc)44{45TR::Compilation *comp = self()->comp();46TR::Linkage *linkage = NULL;4748switch (lc)49{50case TR_CHelper:51linkage = new (self()->trHeapMemory()) J9::X86::HelperLinkage(self());52break;53case TR_Helper:54case TR_Private:55{56J9::X86::PrivateLinkage *p = NULL;57p = new (self()->trHeapMemory()) J9::X86::AMD64::PrivateLinkage(self());58p->IPicParameters.roundedSizeOfSlot = 10+3+2+5+2+2;59p->IPicParameters.defaultNumberOfSlots = 2;60p->IPicParameters.defaultSlotAddress = 0;61p->VPicParameters.roundedSizeOfSlot = 10+3+2+5+2+2;62p->VPicParameters.defaultNumberOfSlots = 1;63p->VPicParameters.defaultSlotAddress = 0;64linkage = p;65}66break;6768case TR_J9JNILinkage:69{70TR::AMD64SystemLinkage *systemLinkage;7172if (comp->target().isWindows())73{74systemLinkage = new (self()->trHeapMemory()) TR::AMD64J9Win64FastCallLinkage(self());75linkage = new (self()->trHeapMemory()) J9::X86::AMD64::JNILinkage(systemLinkage, self());76}77else if (comp->target().isLinux() || comp->target().isOSX())78{79systemLinkage = new (self()->trHeapMemory()) TR::AMD64J9ABILinkage(self());80linkage = new (self()->trHeapMemory()) J9::X86::AMD64::JNILinkage(systemLinkage, self());81}82else83{84TR_ASSERT(0, "linkage not supported: %d\n", lc);85linkage = NULL;86}87}88break;8990case TR_System:91if (comp->target().isWindows())92{93linkage = new (self()->trHeapMemory()) TR::AMD64J9Win64FastCallLinkage(self());94}95else if (comp->target().isLinux() || comp->target().isOSX())96{97linkage = new (self()->trHeapMemory()) TR::AMD64J9ABILinkage(self());98}99else100{101TR_ASSERT(0, "linkage not supported: %d\n", lc);102linkage = NULL;103}104105break;106107default :108TR_ASSERT(0, "\nTestarossa error: Illegal linkage convention %d\n", lc);109}110111self()->setLinkage(lc, linkage);112return linkage;113}114115116