From 4c869a9f18eafa283858e9efdc88b410952fdb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 14 Jan 2020 15:18:33 +0100 Subject: [PATCH] Port changes to crossgen2 shared files (#1709) Changes from dotnet/corert#7944 to enable x86 support. --- .../Target_X86/X86Emitter.cs | 33 +++++++++++++++++-- .../tools/crossgen2/jitinterface/jithost.cpp | 4 +-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/coreclr/src/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs b/src/coreclr/src/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs index a811ab4e6785b..16954470b8acc 100644 --- a/src/coreclr/src/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs +++ b/src/coreclr/src/tools/Common/Compiler/DependencyAnalysis/Target_X86/X86Emitter.cs @@ -18,6 +18,14 @@ public X86Emitter(NodeFactory factory, bool relocsOnly) public ObjectDataBuilder Builder; public TargetRegisterMap TargetRegister; + public void EmitCMP(ref AddrMode addrMode, sbyte immediate) + { + if (addrMode.Size == AddrModeSize.Int16) + Builder.EmitByte(0x66); + EmitIndirInstruction((byte)((addrMode.Size != AddrModeSize.Int8) ? 0x83 : 0x80), 0x7, ref addrMode); + Builder.EmitByte((byte)immediate); + } + public void EmitADD(ref AddrMode addrMode, sbyte immediate) { if (addrMode.Size == AddrModeSize.Int16) @@ -76,7 +84,13 @@ public void EmitPUSH(ISymbolNode node) } } - public void EmitMOV(Register register, ISymbolNode node) + public void EmitMOV(Register regDst, Register regSrc) + { + Builder.EmitByte(0x8B); + Builder.EmitByte((byte)(0xC0 | (((int)regDst & 0x07) << 3) | (((int)regSrc & 0x07)))); + } + + public void EmitMOV(Register register, ISymbolNode node, int delta = 0) { if (node.RepresentsIndirectionCell) { @@ -89,7 +103,7 @@ public void EmitMOV(Register register, ISymbolNode node) // mov register, immediate Builder.EmitByte((byte)(0xB8 + (byte)register)); } - Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_HIGHLOW); + Builder.EmitReloc(node, RelocType.IMAGE_REL_BASED_HIGHLOW, delta); } public void EmitINT3() @@ -97,6 +111,21 @@ public void EmitINT3() Builder.EmitByte(0xCC); } + public void EmitRET() + { + Builder.EmitByte(0xC3); + } + + public void EmitRETIfEqual() + { + // jne @+1 + Builder.EmitByte(0x75); + Builder.EmitByte(0x01); + + // ret + Builder.EmitByte(0xC3); + } + private bool InSignedByteRange(int i) { return i == (int)(sbyte)i; diff --git a/src/coreclr/src/tools/crossgen2/jitinterface/jithost.cpp b/src/coreclr/src/tools/crossgen2/jitinterface/jithost.cpp index f433cf5b1c992..d068e814f92d4 100644 --- a/src/coreclr/src/tools/crossgen2/jitinterface/jithost.cpp +++ b/src/coreclr/src/tools/crossgen2/jitinterface/jithost.cpp @@ -9,12 +9,12 @@ class JitConfigProvider { public: - virtual int getIntConfigValue( + virtual int STDMETHODCALLTYPE getIntConfigValue( const wchar_t* name, int defaultValue ) = 0; - virtual int getStringConfigValue( + virtual int STDMETHODCALLTYPE getStringConfigValue( const wchar_t* name, wchar_t* retBuffer, int retBufferLength