Skip to content

Instantly share code, notes, and snippets.

@sehe

sehe/Makefile

Created Jun 13, 2012
Embed
What would you like to do?
counterexample
#include <iostream>
#include "Register.hpp"
int main(int argc, const char * argv[])
{
std::cout << rax << " " << rbx << std::endl;
return 0;
}
all:main
CPPFLAGS+=-std=c++0x
CPPFLAGS+=-g -O2
CPPFLAGS+=-march=native
%:%.cpp
g++ $(CPPFLAGS) -c $M -o $@ $^
.depends: *.cpp
g++ $(CPPFLAGS) $^ -M > $@
-include .depends
/** Register.hpp **/
#ifndef lss_Register_hpp
#define lss_Register_hpp
#include <string>
#include <ostream>
enum RegisterFlag { CPU };
struct Register
{
const int uniqueId;
const std::string name;
const enum RegisterFlag flag;
Register(int uniqueId, std::string name, enum RegisterFlag flag) : uniqueId(uniqueId), name(name), flag(flag) {}
Register() = delete;
};
std::ostream & operator << (std::ostream &os, const Register &reg)
{
return (os << reg.name);
}
const Register rax(0, "rax", CPU);
const Register rcx(1, "rcx", CPU);
const Register rdx(2, "rdx", CPU);
const Register rbx(3, "rbx", CPU);
const Register rsp(3, "rsp", CPU);
const Register rbp(3, "rbp", CPU);
const Register rsi(3, "rsi", CPU);
const Register rdi(3, "rdi", CPU);
const Register r8(3, "r8", CPU);
const Register r9(3, "r9", CPU);
const Register r10(3, "r10", CPU);
const Register r11(3, "r11", CPU);
const Register r12(3, "r12", CPU);
const Register r13(3, "r13", CPU);
const Register r14(3, "r14", CPU);
const Register r15(3, "r15", CPU);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment