Ticket #5233 (closed feature request: fixed)

Opened 2 years ago

Last modified 8 months ago

Support specifying the assembly that should be generated

Reported by: tibbe Owned by: simonmar
Priority: normal Milestone: 7.8.1
Component: Test Suite Version: 7.0.3
Keywords: Cc: johan.tibell@…, ikke+ghc@…, axman6@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

We want to make sure that native code generator optimizations, like primop unrolling, always fire. We can do this by allowing the programmer to specify what assembly should be generated for a particular snippet of Cmm. The programmer gives a snippet of Cmm:

#include "Cmm.h"

// Large memcpy's should lower to calls.
callMemcpy
{
  W_ dst, src;
  prim %memcpy(dst "ptr", src "ptr", 1024, 4) [];
}

and the expected assembly output:

callMemcpy:
movq  ; Move arguments into place
movq
movl
movl
call memcpy

The expected output shouldn't mention specific register names as these are likely to change.

Attachments

Change History

Changed 2 years ago by tibbe

  • cc johan.tibell@… added
  • status changed from new to patch

I've attached a patch that implements this behavior, together with a first test case.

Changed 23 months ago by igloo

  • milestone set to 7.2.1

Changed 22 months ago by tibbe

  • owner set to simonmar

Changed 20 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • milestone changed from 7.4.1 to 7.6.1

Changed 10 months ago by nicolast

  • cc ikke+ghc@… added

This looks somewhat like LLVM's "FileCheck?" system [1]. Might be useful?

Next to that: maybe removing all register names from the asm to be generated could be replaced by using placeholders (like "Variables" in FileCheck?).

[1]  http://llvm.org/docs/TestingGuide.html#FileCheck

Changed 10 months ago by Axman6

  • cc axman6@… added

Changed 8 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2

Changed 8 months ago by simonmar

  • status changed from patch to closed
  • difficulty set to Unknown
  • resolution set to fixed
  • milestone changed from 7.6.2 to 7.8.1

Committed, thanks:

commit a351a67a242f8484764fe450b973b2d4ac9d098e
Author: Johan Tibell <johan.tibell@gmail.com>
Date:   Tue May 31 11:56:58 2011 +0200

    Make it possible to test the generated assembly
    
    This test framework feature is inspired by a similar feature in LLVM.
    The programmer writes a bit of Cmm
    
        #include "Cmm.h"
    
        // Large memcpy's should lower to calls.
        callMemcpy
        {
          W_ dst, src;
          prim %memcpy(dst "ptr", src "ptr", 1024, 4) [];
        }
    
    and asserts what the generated assembly should look like, modulo
    register naming.
    
        callMemcpy:
        movq  ; Move arguments into place
        movq
        movl
        movl
        call memcpy
    
    Patch edited and updated by Simon Marlow, and I also added a test for
    unrolling memcpy and a simple constant-propagation test.
Note: See TracTickets for help on using tickets.