Skip to content

Commit

Permalink
Added support for Aligned Function Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamnarlawar77 committed Sep 8, 2019
1 parent 061488a commit 27ef2b2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Attribute.cpp
Expand Up @@ -63,3 +63,20 @@ MultiChoiceAttribute::make_random()
else
return "";
}

AlignedAttribute::AlignedAttribute(string name, int prob, int alignment_factor)
: Attribute(name, prob), alignment(alignment_factor)
{
}

string
AlignedAttribute::make_random()
{
if(rnd_flipcoin(prob)){
ostringstream oss;
oss << (1 << rnd_upto(alignment));
return name + "(" + oss.str() + ")";
}
else
return "";
}
12 changes: 12 additions & 0 deletions src/Attribute.h
Expand Up @@ -3,6 +3,7 @@

#include <string>
#include <vector>
#include <sstream>
using namespace std;

class AttributeGenerator;
Expand Down Expand Up @@ -38,6 +39,17 @@ class MultiChoiceAttribute : public Attribute
string make_random();
};

//Generates alignment attribute
class AlignedAttribute : public Attribute
{
public:
//alignment factor - [functions] = 16 and [types] = 8 i.e. functions can take alignment upto 2^16 where as type can take upto 2^8
int alignment;
AlignedAttribute(string, int, int);
string make_random();
};

//Generates function and types attributes
class AttributeGenerator
{
public:
Expand Down
1 change: 1 addition & 0 deletions src/Function.cpp
Expand Up @@ -135,6 +135,7 @@ Function::InitializeAttributes()

func_attr_generator.attributes.push_back(new MultiChoiceAttribute("visibility", FuncAttrProb, visibility_choices));
func_attr_generator.attributes.push_back(new MultiChoiceAttribute("no_sanitize", FuncAttrProb, sanitize_choices));
func_attr_generator.attributes.push_back(new AlignedAttribute("aligned", FuncAttrProb, 16));
}
}

Expand Down

0 comments on commit 27ef2b2

Please sign in to comment.