Created
March 10, 2017 00:12
-
-
Save atiq-cs/1b8266003d682ebfa84baf84b3a4c130 to your computer and use it in GitHub Desktop.
Second version of TryTruncateFloat32ToUint64WithCheck that is working, this code goes into src/compiler/sparc64/code-generator-sparc64.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case kSparcCvtSXu: { | |
Label done; | |
Label success; | |
Label simple; | |
if (instr->OutputCount() > 1) { | |
__ or3(G0, G0, i.OutputRegister(1)); | |
} | |
// NaN | |
__ fcmps(i.InputSingleRegister(0), i.InputSingleRegister(0)); | |
__ fb(f_unordered, true, &done); | |
// if input < 2^63 do simple cvt_s_x | |
// load 2 ^ 63 into kScratchSingleRegister | |
__ or3(G0, 0x5f, kScratchRegister); | |
__ sllx(kScratchRegister, 24, kScratchRegister); | |
__ mov_w_s(kScratchRegister, kScratchSingleRegister); | |
__ fcmps(i.InputSingleRegister(0), kScratchSingleRegister); | |
__ fb(f_less, true, &simple); | |
DoubleRegister scratch0 = kScratchDoubleRegister; | |
DoubleRegister scratch1 = kScratchDoubleRegister1; | |
// DoubleRegister scratch1 = i.TempDoubleRegister(0); | |
// subtract 2^63 from input | |
// load -2^63 into scratch0 and add with input | |
__ or3(G0, 0x61f, kScratchRegister); | |
__ sllx(kScratchRegister, 53, kScratchRegister); | |
__ mov_x_d(kScratchRegister, scratch0); | |
// load input into scratch1 | |
__ cvt_s_d(i.InputSingleRegister(0), scratch1); | |
// scratch0 contains input - 2 ^ 63 | |
__ add_d(scratch0, scratch1, scratch0); | |
// load 2^63 into scratch1 | |
// __ cvt_s_d(kScratchSingleRegister, scratch1); | |
__ or3(G0, 0x21f, kScratchRegister); | |
__ sllx(kScratchRegister, 53, kScratchRegister); | |
__ mov_x_d(kScratchRegister, scratch1); | |
__ fcmpd(scratch0, scratch1); | |
__ fb(f_greaterOrEqual, true, &done); | |
__ cvt_d_x(scratch0, scratch0); | |
__ mov_d_x(scratch0, i.OutputRegister()); | |
// still negative | |
__ subcc(i.OutputRegister(), G0, G0); | |
__ br(negative, &done); | |
// undo subtraction | |
__ or3(G0, 1, kScratchRegister); | |
__ sllx(kScratchRegister, 63, kScratchRegister); | |
__ or3(kScratchRegister, i.OutputRegister(), i.OutputRegister()); | |
__ ba(&success); | |
// simple conversion | |
__ bind(&simple); | |
__ cvt_s_x(i.InputSingleRegister(0), kScratchDoubleRegister); | |
__ mov_d_x(kScratchDoubleRegister, i.OutputRegister()); | |
__ orcc(i.OutputRegister(), i.OutputRegister(), G0); | |
__ br(negative, &done); | |
__ bind(&success); | |
if (instr->OutputCount() > 1) { | |
__ or3(G0, 1, i.OutputRegister(1)); | |
} | |
__ bind(&done); | |
break; | |
} | |
case kSparcCvtDW: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment